diff options
-rw-r--r-- | portal-gui/rpkigui/myrpki/models.py | 18 | ||||
-rw-r--r-- | portal-gui/rpkigui/myrpki/views.py | 12 | ||||
-rw-r--r-- | portal-gui/rpkigui/templates/myrpki/asn_view.html | 2 | ||||
-rw-r--r-- | portal-gui/rpkigui/templates/myrpki/child_view.html | 2 | ||||
-rw-r--r-- | portal-gui/rpkigui/templates/myrpki/conf_list.html | 4 | ||||
-rw-r--r-- | portal-gui/rpkigui/templates/myrpki/dashboard.html | 12 | ||||
-rw-r--r-- | portal-gui/rpkigui/templates/myrpki/parent_view.html | 2 | ||||
-rw-r--r-- | portal-gui/rpkigui/templates/myrpki/prefix_view.html | 2 |
8 files changed, 26 insertions, 28 deletions
diff --git a/portal-gui/rpkigui/myrpki/models.py b/portal-gui/rpkigui/myrpki/models.py index c78e9792..7db5ef1d 100644 --- a/portal-gui/rpkigui/myrpki/models.py +++ b/portal-gui/rpkigui/myrpki/models.py @@ -71,8 +71,9 @@ class AddressRange(models.Model): print err return u'%s - %s' % (self.lo, self.hi) + @models.permalink def get_absolute_url(self): - return u'/myrpki/address/%d' % (self.pk,) + return ('rpkigui.myrpki.views.address_view', [str(self.pk)]) def as_resource_range(self): '''Convert to rpki.resource_set.resource_range_ip.''' @@ -107,9 +108,6 @@ class RoaRequest(models.Model): return rpki.resource_set.roa_prefix_ipv6(r.min, r.prefixlen(), self.max_length) - def get_absolute_url(self): - return u'/myrpki/roa/%d' % (self.pk,) - class Asn(models.Model): '''An ASN or range thereof.''' lo = models.IntegerField(blank=False) @@ -127,8 +125,9 @@ class Asn(models.Model): else: return u"ASNs %d - %d" % (self.lo, self.hi) + @models.permalink def get_absolute_url(self): - return u'/myrpki/asn/%d' % (self.pk,) + return ('rpkigui.myrpki.views.asn_view', [str(self.pk)]) def as_resource_range(self): # we force conversion to long() here because resource_range_as() wants @@ -143,8 +142,9 @@ class Child(models.Model): def __unicode__(self): return u"%s's child %s" % (self.conf, self.handle) + @models.permalink def get_absolute_url(self): - return u'/myrpki/child/%s' % (self.handle,) + return ('rpkigui.myrpki.views.child_view', [self.handle]) class Meta: verbose_name_plural = "children" @@ -158,8 +158,9 @@ class Parent(models.Model): def __unicode__(self): return u"%s's parent %s" % (self.conf, self.handle) + @models.permalink def get_absolute_url(self): - return u'/myrpki/parent/%s' % (self.handle,) + return ('rpkigui.myrpki.views.parent_view', [self.handle]) class Meta: # parents of a specific configuration should be unique @@ -183,9 +184,6 @@ class ResourceCert(models.Model): not_before = models.DateTimeField() not_after = models.DateTimeField() - def get_absolute_url(self): - return u"/myrpki/resource/%d" % (self.pk,) - def __unicode__(self): return u"%s's resource cert from parent %s" % (self.parent.conf.handle, self.parent.handle) diff --git a/portal-gui/rpkigui/myrpki/views.py b/portal-gui/rpkigui/myrpki/views.py index b3c69013..206d334f 100644 --- a/portal-gui/rpkigui/myrpki/views.py +++ b/portal-gui/rpkigui/myrpki/views.py @@ -30,6 +30,7 @@ from django import http from django.views.generic.list_detail import object_list from django.views.decorators.csrf import csrf_exempt from django.conf import settings +from django.core.urlresolvers import reverse from rpkigui.myrpki import models, forms, glue, misc, AllocationTree from rpkigui.myrpki.asnset import asnset @@ -57,8 +58,7 @@ def handle_required(f): # Should reverse the view for this instead of hardcoding # the URL. return http.HttpResponseRedirect( - '/myrpki/conf/list?next=%s' % - urlquote(request.get_full_path())) + reverse(conf_list) + '?next=' + urlquote(request.get_full_path())) request.session[ 'handle' ] = handle return f(request, *args, **kwargs) return wrapped_fn @@ -138,7 +138,7 @@ def conf_list(request): else: queryset = models.Conf.objects.filter(owner=request.user) return object_list(request, queryset, - template_name='myrpki/conf_list.html', template_object_name='conf') + template_name='myrpki/conf_list.html', template_object_name='conf', extra_context={ 'select_url' : reverse(conf_select) }) @login_required def conf_select(request): @@ -146,9 +146,9 @@ def conf_select(request): if not 'handle' in request.GET: return http.HttpResponseRedirect('/myrpki/conf/select') handle = request.GET['handle'] - next_url = request.GET.get('next', '/myrpki/') + next_url = request.GET.get('next', reverse(dashboard)) if next_url == '': - next_url = '/myrpki/' + next_url = reverse(dashboard) if request.user.is_superuser: conf = models.Conf.objects.filter(handle=handle) @@ -161,7 +161,7 @@ def conf_select(request): request.session['handle'] = conf[0] return http.HttpResponseRedirect(next_url) - return http.HttpResponseRedirect('/myrpki/conf/list?next=' + next_url) + return http.HttpResponseRedirect(reverse(conf_list) + '?next=' + next_url) def serve_xml(content, basename): resp = http.HttpResponse(content , mimetype='application/xml') diff --git a/portal-gui/rpkigui/templates/myrpki/asn_view.html b/portal-gui/rpkigui/templates/myrpki/asn_view.html index 3ab2fe25..ef020355 100644 --- a/portal-gui/rpkigui/templates/myrpki/asn_view.html +++ b/portal-gui/rpkigui/templates/myrpki/asn_view.html @@ -7,7 +7,7 @@ td { border: solid 1px; text-align: center; padding-left: 1em; padding-right: 1e {% endblock %} {% block content %} -<p>Handle: <a href="/myrpki/">{{ request.session.handle }}</a> +<p>Handle: <a href="{% url rpkigui.myrpki.views.dashboard %}">{{ request.session.handle }}</a> <h1>ASN View</h1> diff --git a/portal-gui/rpkigui/templates/myrpki/child_view.html b/portal-gui/rpkigui/templates/myrpki/child_view.html index 718e089d..62709f0d 100644 --- a/portal-gui/rpkigui/templates/myrpki/child_view.html +++ b/portal-gui/rpkigui/templates/myrpki/child_view.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {% block content %} -<p>Handle: <a href="/myrpki/">{{ request.session.handle.handle }}</a> +<p>Handle: <a href="{% url rpkigui.myrpki.views.dashboard %}">{{ request.session.handle.handle }}</a> <h1>Child View</h1> <p>Child: {{ child.handle }} diff --git a/portal-gui/rpkigui/templates/myrpki/conf_list.html b/portal-gui/rpkigui/templates/myrpki/conf_list.html index 9f350ef4..4bb18114 100644 --- a/portal-gui/rpkigui/templates/myrpki/conf_list.html +++ b/portal-gui/rpkigui/templates/myrpki/conf_list.html @@ -2,11 +2,11 @@ {% block content %} <h1>Handle List</h1> -<p>Please select a handle. +<p>Please select a handle.</p> <ul> {% for c in conf_list %} -<li><a href="/myrpki/conf/select?handle={{ c.handle }}&next={{ next_url }}">{{ c.handle }}</a> +<li><a href="{{ select_url }}?handle={{ c.handle }}&next={{ next_url }}">{{ c.handle }}</a></li> {% endfor %} </ul> diff --git a/portal-gui/rpkigui/templates/myrpki/dashboard.html b/portal-gui/rpkigui/templates/myrpki/dashboard.html index 6be83b76..af99e89e 100644 --- a/portal-gui/rpkigui/templates/myrpki/dashboard.html +++ b/portal-gui/rpkigui/templates/myrpki/dashboard.html @@ -8,8 +8,8 @@ td { border: solid 1px; text-align: center; padding-left: 1em; padding-right: 1e {% block content %} <p>Handle: {{ request.session.handle }} -| <a href="/myrpki/conf/export">export identity</a> -| <a href="/myrpki/conf/list">select</a> +| <a href="{% url rpkigui.myrpki.views.conf_export %}">export identity</a> +| <a href="{% url rpkigui.myrpki.views.conf_list %}">select</a> <div style="border: inset"> <h1 style="text-align: center">Parents</h1> @@ -54,7 +54,7 @@ td { border: solid 1px; text-align: center; padding-left: 1em; padding-right: 1e {% if request.session.handle.children.all %} <ul> {% for child in request.session.handle.children.all %} -<li><a href="/myrpki/child/{{ child.handle }}">{{ child.handle }}</a> +<li><a href="{% url rpkigui.myrpki.views.child_view child.handle %}">{{ child.handle }}</a> {% if child.address_range.count or child.asn.count %} <p>Delegated resources: <ul> @@ -76,8 +76,8 @@ td { border: solid 1px; text-align: center; padding-left: 1em; padding-right: 1e {% endif %} <p> -Export (csv): <a href="/myrpki/demo/down/asns/{{ request.session.handle }}">asns</a> | -<a href="/myrpki/demo/down/prefixes/{{ request.session.handle }}">prefixes</a> +Export (csv): <a href="{% url rpkigui.myrpki.views.download_asns request.session.handle %}">asns</a> | +<a href="{% url rpkigui.myrpki.views.download_prefixes request.session.handle %}">prefixes</a> </div> @@ -101,7 +101,7 @@ Export (csv): <a href="/myrpki/demo/down/asns/{{ request.session.handle }}">asns {% endfor %} </table> -<p><a href="/myrpki/demo/down/roas/{{ request.session.handle }}">export (csv)</a> +<p><a href="{% url rpkigui.myrpki.views.download_roas request.session.handle %}">export (csv)</a> </div><!-- roas --> diff --git a/portal-gui/rpkigui/templates/myrpki/parent_view.html b/portal-gui/rpkigui/templates/myrpki/parent_view.html index 41411375..e1852245 100644 --- a/portal-gui/rpkigui/templates/myrpki/parent_view.html +++ b/portal-gui/rpkigui/templates/myrpki/parent_view.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {% block content %} -<p>Handle: <a href="/myrpki/">{{ request.session.handle.handle }}</a> +<p>Handle: <a href="{% url rpkigui.myrpki.views.dashboard %}">{{ request.session.handle.handle }}</a> <h1>Parent View</h1> <p>Parent: {{ parent.handle }} <h2>Delegated Addresses</h2> diff --git a/portal-gui/rpkigui/templates/myrpki/prefix_view.html b/portal-gui/rpkigui/templates/myrpki/prefix_view.html index d26cbdff..1e1ca797 100644 --- a/portal-gui/rpkigui/templates/myrpki/prefix_view.html +++ b/portal-gui/rpkigui/templates/myrpki/prefix_view.html @@ -7,7 +7,7 @@ td { border: solid 1px; text-align: center; padding-left: 1em; padding-right: 1e {% endblock %} {% block content %} -<p>Handle: <a href="/myrpki/">{{ request.session.handle }}</a> +<p>Handle: <a href="{% url rpkigui.myrpki.views.dashboard %}">{{ request.session.handle }}</a> <h1>Prefix View</h1> |