diff options
author | Michael Elkins <melkins@tislabs.com> | 2013-03-28 22:29:12 +0000 |
---|---|---|
committer | Michael Elkins <melkins@tislabs.com> | 2013-03-28 22:29:12 +0000 |
commit | e52135d4cbde49d0822cac6c68c1c10b775d3dcb (patch) | |
tree | b608f8902b73268afda2591efbd6079e8faf5c8e | |
parent | d2847b67f9a8a25e92af61d6abe5efafc92d9ead (diff) |
allow user to create roas by selecting entries from the route view
see #325
svn path=/trunk/; revision=5240
-rw-r--r-- | rpkid/rpki/gui/app/templates/app/routes_view.html | 6 | ||||
-rw-r--r-- | rpkid/rpki/gui/app/urls.py | 1 | ||||
-rw-r--r-- | rpkid/rpki/gui/app/views.py | 21 |
3 files changed, 28 insertions, 0 deletions
diff --git a/rpkid/rpki/gui/app/templates/app/routes_view.html b/rpkid/rpki/gui/app/templates/app/routes_view.html index 8ea6da2e..8e6edd3f 100644 --- a/rpkid/rpki/gui/app/templates/app/routes_view.html +++ b/rpkid/rpki/gui/app/templates/app/routes_view.html @@ -23,9 +23,12 @@ rcynic cache updated<br> <p> This view shows currently advertised routes for the prefixes listed in resource certs received from RPKI parents. +<form method="POST" action="{% url "suggest-roas" %}"> + {% csrf_token %} <table class='table table-striped table-condensed'> <thead> <tr> + <th></th> <th>Prefix</th> <th>Origin AS</th> <th>Validation Status</th> @@ -34,6 +37,7 @@ This view shows currently advertised routes for the prefixes listed in resource <tbody> {% for r in routes %} <tr> + <td><input type="checkbox" name="pk-{{ r.pk }}"></td> <td>{{ r.get_prefix_display }}</td> <td>{{ r.asn }}</td> <td> @@ -44,6 +48,8 @@ This view shows currently advertised routes for the prefixes listed in resource {% endfor %} </tbody> </table> +<button type="submit" title="create ROAs for selected routes"><i class="icon-plus-sign"></i> Create ROAs</button> +</form> {% bootstrap_pager request routes %} diff --git a/rpkid/rpki/gui/app/urls.py b/rpkid/rpki/gui/app/urls.py index e638091b..5f7c214c 100644 --- a/rpkid/rpki/gui/app/urls.py +++ b/rpkid/rpki/gui/app/urls.py @@ -67,6 +67,7 @@ urlpatterns = patterns( url(r'^roa/(?P<pk>\d+)/clone$', views.roa_clone, name="roa-clone"), (r'^route/$', views.route_view), (r'^route/(?P<pk>\d+)/$', views.route_detail), + url(r'^route/suggest$', views.route_suggest, name="suggest-roas"), (r'^user/$', views.user_list), (r'^user/create$', views.user_create), (r'^user/(?P<pk>\d+)/delete$', views.user_delete), diff --git a/rpkid/rpki/gui/app/views.py b/rpkid/rpki/gui/app/views.py index a6b7f95f..ac4c0858 100644 --- a/rpkid/rpki/gui/app/views.py +++ b/rpkid/rpki/gui/app/views.py @@ -954,6 +954,27 @@ def route_detail(request, pk): route = get_object_or_404(models.RouteOrigin, pk=pk) return render(request, 'app/route_detail.html', {'object': route}) + +def route_suggest(request): + """Handles POSTs from the route view and redirects to the ROA creation + page based on selected route objects. The form should contain elements of + the form "pk-NUM" where NUM is the RouteOrigin object id. + + """ + if request.method == 'POST': + routes = [] + for pk in request.POST.iterkeys(): + logger.debug(pk) + if pk.startswith("pk-"): + n = int(pk[3:]) + routes.append(n) + qs = RouteOrigin.objects.filter(pk__in=routes) + s = [] + for r in qs: + s.append('roa=%s/%d,%d' % (str(r.prefix_min), r.prefixlen, r.asn)) + p = '&'.join(s) + return redirect(reverse(roa_create_multi) + '?' + p) + @handle_required def repository_detail(request, pk): |