aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Elkins <melkins@tislabs.com>2012-02-04 00:50:00 +0000
committerMichael Elkins <melkins@tislabs.com>2012-02-04 00:50:00 +0000
commit731bb8717740f388c4ba64d0f5cc17e02c90b926 (patch)
treed9bcb982f889044651de649b7e2e9f4914265daa
parentfb10cf125f4fa5506ee321f50dee539806156433 (diff)
format models.py according to pep8
use narrower spans to display multi column fields in some templates to avoid unnecessary wrapping when the window is narrow add titles to buttons for some actions to provide some user help svn path=/branches/tk161/; revision=4291
-rw-r--r--rpkid/rpki/gui/app/models.py114
-rw-r--r--rpkid/rpki/gui/app/templates/app/child_detail.html10
-rw-r--r--rpkid/rpki/gui/app/templates/app/client_detail.html28
-rw-r--r--rpkid/rpki/gui/app/templates/app/object_detail.html2
-rw-r--r--rpkid/rpki/gui/app/templates/app/parent_detail.html8
-rw-r--r--rpkid/rpki/gui/app/templates/app/parent_list.html2
-rw-r--r--rpkid/rpki/gui/app/templates/app/repository_detail.html4
7 files changed, 95 insertions, 73 deletions
diff --git a/rpkid/rpki/gui/app/models.py b/rpkid/rpki/gui/app/models.py
index a44e21d7..62e3a141 100644
--- a/rpkid/rpki/gui/app/models.py
+++ b/rpkid/rpki/gui/app/models.py
@@ -1,53 +1,52 @@
-# $Id$
-"""
-Copyright (C) 2010 SPARTA, Inc. dba Cobham Analytic Solutions
-Copyright (C) 2012 SPARTA, Inc. a Parsons Company
-
-Permission to use, copy, modify, and distribute this software for any
-purpose with or without fee is hereby granted, provided that the above
-copyright notice and this permission notice appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND SPARTA DISCLAIMS ALL WARRANTIES WITH
-REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-AND FITNESS. IN NO EVENT SHALL SPARTA BE LIABLE FOR ANY SPECIAL, DIRECT,
-INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-PERFORMANCE OF THIS SOFTWARE.
-"""
-
-import socket
+# Copyright (C) 2010 SPARTA, Inc. dba Cobham Analytic Solutions
+# Copyright (C) 2012 SPARTA, Inc. a Parsons Company
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND SPARTA DISCLAIMS ALL WARRANTIES WITH
+# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS. IN NO EVENT SHALL SPARTA BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+
+__version__ = '$Id$'
from django.db import models
-from django.contrib.auth.models import User
import rpki.resource_set
import rpki.exceptions
import rpki.irdb.models
import rpki.gui.models
+
class TelephoneField(models.CharField):
- def __init__( self, **kwargs ):
+ def __init__(self, **kwargs):
models.CharField.__init__(self, max_length=40, **kwargs)
+
class Parent(rpki.irdb.models.Parent):
"""proxy model for irdb Parent"""
def __unicode__(self):
- return u"%s's parent %s" % (self.issuer.handle, self.handle)
+ return u"%s's parent %s" % (self.issuer.handle, self.handle)
@models.permalink
def get_absolute_url(self):
- return ('rpki.gui.app.views.parent_view', [str(self.pk)])
+ return ('rpki.gui.app.views.parent_detail', [str(self.pk)])
class Meta:
proxy = True
+
class Child(rpki.irdb.models.Child):
"""proxy model for irdb Child"""
def __unicode__(self):
- return u"%s's child %s" % (self.issuer.handle, self.handle)
+ return u"%s's child %s" % (self.issuer.handle, self.handle)
@models.permalink
def get_absolute_url(self):
@@ -79,28 +78,37 @@ class ChildNet(rpki.irdb.models.ChildNet):
class Conf(rpki.irdb.models.ResourceHolderCA):
- '''This is the center of the universe, also known as a place to
+ """This is the center of the universe, also known as a place to
have a handle on a resource-holding entity. It's the <self>
- in the rpkid schema.'''
+ in the rpkid schema.
+ """
@property
def parents(self):
- """Simulates irdb.models.Parent.objects, but returns app.models.Parent proxy objects."""
+ """Simulates irdb.models.Parent.objects, but returns app.models.Parent
+ proxy objects.
+
+ """
return Parent.objects.filter(issuer=self)
@property
def children(self):
- """Simulates irdb.models.Child.objects, but returns app.models.Child proxy objects."""
+ """Simulates irdb.models.Child.objects, but returns app.models.Child
+ proxy objects.
+
+ """
return Child.objects.filter(issuer=self)
class Meta:
proxy = True
+
class ResourceCert(models.Model):
"""Represents a resource certificate.
- This model is used to cache the output of <list_received_resources/>."""
+ This model is used to cache the output of <list_received_resources/>.
+ """
# pointer to the parent object in the irdb
parent = models.ForeignKey(Parent, related_name='certs')
@@ -113,17 +121,22 @@ class ResourceCert(models.Model):
uri = models.CharField(max_length=255)
def __unicode__(self):
- return u"%s's resource cert from parent %s" % (self.parent.issuer.handle, self.parent.handle)
+ return u"%s's cert from %s" % (self.parent.issuer.handle,
+ self.parent.handle)
+
class ResourceRangeAddressV4(rpki.gui.models.PrefixV4):
cert = models.ForeignKey(ResourceCert, related_name='address_ranges')
+
class ResourceRangeAddressV6(rpki.gui.models.PrefixV6):
cert = models.ForeignKey(ResourceCert, related_name='address_ranges_v6')
+
class ResourceRangeAS(rpki.gui.models.ASN):
cert = models.ForeignKey(ResourceCert, related_name='asn_ranges')
+
class ROARequest(rpki.irdb.models.ROARequest):
class Meta:
proxy = True
@@ -131,18 +144,21 @@ class ROARequest(rpki.irdb.models.ROARequest):
def __unicode__(self):
return u"%s's ROA request for AS%d" % (self.issuer.handle, self.asn)
+
class ROARequestPrefix(rpki.irdb.models.ROARequestPrefix):
class Meta:
proxy = True
verbose_name = 'roa'
def __unicode__(self):
- return u'ROA request prefix %s for asn %d' % (str(self.as_roa_prefix()), self.roa_request.asn)
+ return u'ROA request prefix %s for asn %d' % (str(self.as_roa_prefix()),
+ self.roa_request.asn)
@models.permalink
def get_absolute_url(self):
return ('rpki.gui.app.views.roa_detail', [str(self.pk)])
+
class GhostbusterRequest(rpki.irdb.models.GhostbusterRequest):
"""
Stores the information require to fill out a vCard entry to
@@ -155,24 +171,27 @@ class GhostbusterRequest(rpki.irdb.models.GhostbusterRequest):
full_name = models.CharField(max_length=40)
# components of the vCard N type
- family_name = models.CharField(max_length=20)
- given_name = models.CharField(max_length=20)
- additional_name = models.CharField(max_length=20, blank=True, null=True)
+ family_name = models.CharField(max_length=20)
+ given_name = models.CharField(max_length=20)
+ additional_name = models.CharField(max_length=20, blank=True, null=True)
honorific_prefix = models.CharField(max_length=10, blank=True, null=True)
honorific_suffix = models.CharField(max_length=10, blank=True, null=True)
- email_address = models.EmailField(blank=True, null=True)
- organization = models.CharField(blank=True, null=True, max_length=255)
- telephone = TelephoneField(blank=True, null=True)
+ email_address = models.EmailField(blank=True, null=True)
+ organization = models.CharField(blank=True, null=True, max_length=255)
+ telephone = TelephoneField(blank=True, null=True)
# elements of the ADR type
- box = models.CharField(verbose_name='P.O. Box', blank=True, null=True, max_length=40)
+ box = models.CharField(verbose_name='P.O. Box', blank=True, null=True,
+ max_length=40)
extended = models.CharField(blank=True, null=True, max_length=255)
- street = models.CharField(blank=True, null=True, max_length=255)
- city = models.CharField(blank=True, null=True, max_length=40)
- region = models.CharField(blank=True, null=True, max_length=40, help_text='state or province')
- code = models.CharField(verbose_name='Postal Code', blank=True, null=True, max_length=40)
- country = models.CharField(blank=True, null=True, max_length=40)
+ street = models.CharField(blank=True, null=True, max_length=255)
+ city = models.CharField(blank=True, null=True, max_length=40)
+ region = models.CharField(blank=True, null=True, max_length=40,
+ help_text='state or province')
+ code = models.CharField(verbose_name='Postal Code', blank=True, null=True,
+ max_length=40)
+ country = models.CharField(blank=True, null=True, max_length=40)
def __unicode__(self):
return u"%s's GBR: %s" % (self.issuer.handle, self.full_name)
@@ -185,12 +204,13 @@ class GhostbusterRequest(rpki.irdb.models.GhostbusterRequest):
ordering = ('family_name', 'given_name')
verbose_name = 'ghostbuster'
+
class Timestamp(models.Model):
"""Model to hold metadata about the collection of external data.
-
+
This model is a hash table mapping a timestamp name to the
timestamp value. All timestamps values are in UTC.
-
+
The utility function rpki.gui.app.timestmap.update(name) should be used to
set timestamps rather than updating this model directly."""
@@ -200,6 +220,7 @@ class Timestamp(models.Model):
def __unicode__(self):
return '%s: %s' % (self.name, self.ts)
+
class Repository(rpki.irdb.models.Repository):
class Meta:
proxy = True
@@ -212,6 +233,7 @@ class Repository(rpki.irdb.models.Repository):
def __unicode__(self):
return "%s's repository %s" % (self.issuer.handle, self.handle)
+
class Client(rpki.irdb.models.Client):
"Proxy model for pubd clients."
@@ -224,5 +246,3 @@ class Client(rpki.irdb.models.Client):
def __unicode__(self):
return self.handle
-
-# vim:sw=4 ts=8 expandtab
diff --git a/rpkid/rpki/gui/app/templates/app/child_detail.html b/rpkid/rpki/gui/app/templates/app/child_detail.html
index 8c242d04..b180633d 100644
--- a/rpkid/rpki/gui/app/templates/app/child_detail.html
+++ b/rpkid/rpki/gui/app/templates/app/child_detail.html
@@ -19,7 +19,7 @@
</div>
<div class='row'>
- <div class='span8'>
+ <div class='span4'>
<strong>Addresses</strong>
{% if object.address_ranges.all %}
<ul class='unstyled'>
@@ -31,7 +31,7 @@
<p style='font-style:italic'>none</p>
{% endif %}
</div>
- <div class='span8'>
+ <div class='span4'>
<strong>ASNs</strong>
{% if object.asns.all %}
<ul class='unstyled'>
@@ -47,7 +47,7 @@
{% endblock object_detail %}
{% block actions %}
-<a class='btn' href="{{ object.get_absolute_url }}/add_asn">Delegate AS</a>
-<a class='btn' href="{{ object.get_absolute_url }}/add_address">Delegate Prefix</a>
-<a class='btn' href="{{ object.get_absolute_url }}/export">Export Response</a>
+<a class='btn' href="{{ object.get_absolute_url }}/add_asn" title='Delegate an ASN to this child'>+AS</a>
+<a class='btn' href="{{ object.get_absolute_url }}/add_address" title='Delegate a prefix to this child'>+Prefix</a>
+<a class='btn' href="{{ object.get_absolute_url }}/export" title='Download XML file to send to child'>Export</a>
{% endblock actions %}
diff --git a/rpkid/rpki/gui/app/templates/app/client_detail.html b/rpkid/rpki/gui/app/templates/app/client_detail.html
index 2044abb6..4755fbca 100644
--- a/rpkid/rpki/gui/app/templates/app/client_detail.html
+++ b/rpkid/rpki/gui/app/templates/app/client_detail.html
@@ -1,16 +1,20 @@
{% extends "app/object_detail.html" %}
{% block object_detail %}
-<table style='condensed-table'>
- <tr>
- <th>Name</th>
- <td>{{ object.handle }}</td>
- </tr>
- <tr>
- <th>SIA</th>
- <td>{{ object.sia_base }}</td>
- </tr>
-</table>
+<div class='row'>
+ <div class='span2'>
+ <p><strong>Name</strong>
+ </div>
+ <div class='span6'>
+ <p>{{ object.handle }}
+ </div>
+</div>
+<div class='row'>
+ <div class='span2'>
+ <p><strong>SIA</strong>
+ </div>
+ <div class='span6'>
+ <p>{{ object.sia_base }}
+ </div>
+</div>
{% endblock object_detail %}
-
-<!-- vim:set sw=2: -->
diff --git a/rpkid/rpki/gui/app/templates/app/object_detail.html b/rpkid/rpki/gui/app/templates/app/object_detail.html
index 44c1a797..b73fb681 100644
--- a/rpkid/rpki/gui/app/templates/app/object_detail.html
+++ b/rpkid/rpki/gui/app/templates/app/object_detail.html
@@ -26,7 +26,7 @@
{% if can_edit %}
<a class='btn' href='{{ object.get_absolute_url }}/edit'>Edit</a>
{% endif %}
- <a class='btn danger' href='{{ object.get_absolute_url }}/delete' title='permanently delete this object'>Delete</a>
+ <a class='btn danger' href='{{ object.get_absolute_url }}/delete' title='Permanently delete this object'>Delete</a>
{% block actions %}{% endblock actions %}
</div>
{% endif %}
diff --git a/rpkid/rpki/gui/app/templates/app/parent_detail.html b/rpkid/rpki/gui/app/templates/app/parent_detail.html
index 58aa8050..158b0d8d 100644
--- a/rpkid/rpki/gui/app/templates/app/parent_detail.html
+++ b/rpkid/rpki/gui/app/templates/app/parent_detail.html
@@ -3,7 +3,7 @@
{% block object_detail %}
<h2>{{ object.handle }}</h2>
<div class='row'>
- <div class='span8'>
+ <div class='span4'>
<h3>Delegated Addresses</h3>
<ul class='unstyled'>
{% for c in object.certs.all %}
@@ -16,7 +16,7 @@
{% endfor %}
</ul>
</div>
- <div class='span8'>
+ <div class='span4'>
<h3>Delegated ASNs</h3>
<ul class='unstyled'>
{% for c in object.certs.all %}
@@ -26,9 +26,9 @@
{% endfor %}
</ul>
</div>
-</div><!-- /row -->
+</div>
{% endblock object_detail %}
{% block actions %}
-<a class='btn' href='{{ object.get_absolute_url }}/export' title='Export XML repository request'>Export</a>
+<a class='btn' href='{{ object.get_absolute_url }}/export' title='Download XML to send to repository operator'>Export</a>
{% endblock actions %}
diff --git a/rpkid/rpki/gui/app/templates/app/parent_list.html b/rpkid/rpki/gui/app/templates/app/parent_list.html
index 9ba31ffd..81744130 100644
--- a/rpkid/rpki/gui/app/templates/app/parent_list.html
+++ b/rpkid/rpki/gui/app/templates/app/parent_list.html
@@ -3,5 +3,3 @@
{% block object_detail %}
<li><a href="{{ object.get_absolute_url }}">{{ object.handle }}</a></li>
{% endblock object_detail %}
-
-<!-- vim: set sw=2: -->
diff --git a/rpkid/rpki/gui/app/templates/app/repository_detail.html b/rpkid/rpki/gui/app/templates/app/repository_detail.html
index 4ef6a63f..599357bd 100644
--- a/rpkid/rpki/gui/app/templates/app/repository_detail.html
+++ b/rpkid/rpki/gui/app/templates/app/repository_detail.html
@@ -5,7 +5,7 @@
<div class='span2'>
<p><strong>Name</strong>
</div>
- <div class='span14'>
+ <div class='span6'>
<p>{{ object.handle }}
</div>
</div>
@@ -13,7 +13,7 @@
<div class='span2'>
<p><strong>SIA</strong>
</div>
- <div class='span14'>
+ <div class='span6'>
<p>{{ object.sia_base }}</td>
</div>
</div>