diff options
author | Michael Elkins <melkins@tislabs.com> | 2011-04-07 04:11:16 +0000 |
---|---|---|
committer | Michael Elkins <melkins@tislabs.com> | 2011-04-07 04:11:16 +0000 |
commit | ecf3fef1d589f2f63a6a500172763d753188ec6d (patch) | |
tree | f3117b0ced530f9d9592dacd2bf5a23073be9958 | |
parent | 9c59c55d2205457ad23044f526408cd21abba05b (diff) |
ADR vcard type is not a string, but a compound object
svn path=/rpkid/rpki/gui/app/glue.py; revision=3766
-rw-r--r-- | rpkid/rpki/gui/app/glue.py | 7 | ||||
-rw-r--r-- | rpkid/rpki/gui/app/models.py | 10 | ||||
-rw-r--r-- | rpkid/rpki/gui/app/templates/rpkigui/ghostbuster_detail.html | 29 |
3 files changed, 42 insertions, 4 deletions
diff --git a/rpkid/rpki/gui/app/glue.py b/rpkid/rpki/gui/app/glue.py index 7164e829..cc2ed607 100644 --- a/rpkid/rpki/gui/app/glue.py +++ b/rpkid/rpki/gui/app/glue.py @@ -104,12 +104,17 @@ def ghostbuster_to_vcard(gbr): vcard = vobject.vCard() vcard.add('N').value = vobject.vcard.Name(family=gbr.family_name, given=gbr.given_name) + + adr_fields = [ 'box', 'extended', 'street', 'city', 'region', 'code', 'country' ] + adr_dict = dict((f, getattr(gbr, f, '')) for f in adr_fields) + if any(adr_dict.itervalues()): + vcard.add('ADR').value = vobject.vcard.Address(**adr_dict) + # mapping from vCard type to Ghostbuster model field # the ORG type is a sequence of organization unit names, so # transform the org name into a tuple before stuffing into the # vCard object attrs = [ ('FN', 'full_name', None), - ('ADR', 'postal_address', None), ('TEL', 'telephone', None), ('ORG', 'organization', lambda x: (x,)), ('EMAIL', 'email_address', None) ] diff --git a/rpkid/rpki/gui/app/models.py b/rpkid/rpki/gui/app/models.py index 12574ddc..7ae0eaad 100644 --- a/rpkid/rpki/gui/app/models.py +++ b/rpkid/rpki/gui/app/models.py @@ -241,10 +241,18 @@ class Ghostbuster(models.Model): honorific_suffix = models.CharField(max_length=10, blank=True, null=True) email_address = models.EmailField(blank=True, null=True) - postal_address = models.CharField(blank=True, null=True, max_length=255) 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) + 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) + conf = models.ForeignKey(Conf, related_name='ghostbusters') # parent can be null when using the same record for all parents parent = models.ManyToManyField(Parent, related_name='ghostbusters', diff --git a/rpkid/rpki/gui/app/templates/rpkigui/ghostbuster_detail.html b/rpkid/rpki/gui/app/templates/rpkigui/ghostbuster_detail.html index cb03ec4e..4a9ed73a 100644 --- a/rpkid/rpki/gui/app/templates/rpkigui/ghostbuster_detail.html +++ b/rpkid/rpki/gui/app/templates/rpkigui/ghostbuster_detail.html @@ -36,9 +36,34 @@ td.label { font-weight:bold } <tr><td class='label'>Email</td><td>{{ object.email_address }}</td></tr> {% endif %} - {% if object.postal_address %} - <tr><td class='label'>Postal Address</td><td>{{ object.postal_address }}</td></tr> + {% if object.box %} + <tr><td class='label'>P.O. Box</td><td>{{ object.box }}</td></tr> {% endif %} + + {% if object.extended %} + <tr><td class='label'>Extended Address</td><td>{{ object.extended }}</td></tr> + {% endif %} + + {% if object.street %} + <tr><td class='label'>Street Address</td><td>{{ object.street }}</td></tr> + {% endif %} + + {% if object.city %} + <tr><td class='label'>City</td><td>{{ object.city }}</td></tr> + {% endif %} + + {% if object.region %} + <tr><td class='label'>Region</td><td>{{ object.region }}</td></tr> + {% endif %} + + {% if object.code %} + <tr><td class='label'>Postal Code</td><td>{{ object.code }}</td></tr> + {% endif %} + + {% if object.country %} + <tr><td class='label'>Country</td><td>{{ object.country }}</td></tr> + {% endif %} + </table> {% block extra %}{% endblock %} {% endblock %} |