Commit 427a7daf authored by Graziella Toutoungis's avatar Graziella Toutoungis
Browse files

add relation postal_address and the corresponding view and migrate it

parent da1ecdb040ae
add_relation_definition('Person', 'postal_address', 'PostalAddress')
class Person(EntityType):
"""a physical person"""
surname = String(required=True, fulltextindexed=True, indexed=True, maxsize=64)
......@@ -11,6 +10,8 @@ class Person(EntityType):
if 'PhoneNumber' in defined_types: # from addressbook package
phone = SubjectRelation('PhoneNumber', composite='subject')
if 'PostalAddress' in defined_types:
postal_address = SubjectRelation('PostalAddress', composite='subject')
use_email = SubjectRelation('EmailAddress', cardinality='*1', composite='subject')
# allowing an email to be the primary email of multiple persons is necessary for
......@@ -18,3 +19,4 @@ class Person(EntityType):
primary_email = SubjectRelation('EmailAddress', cardinality='??',
constraints= [RQLConstraint('S use_email O')])
......@@ -18,7 +18,7 @@ for rtype in ('phone', 'use_email', 'primary_email'):
uicfg.primaryview_section.tag_subject_of(('Person', rtype, '*'), 'hidden')
uicfg.autoform_is_inlined.tag_subject_of(('Person', 'phone', '*'), True)
uicfg.autoform_is_inlined.tag_subject_of(('Person', 'postal_address', '*'), True)
class PersonPrimaryView(primary.PrimaryView):
__select__ = implements('Person')
......@@ -30,6 +30,14 @@ class PersonPrimaryView(primary.PrimaryView):
if entity.use_email:
', '.join(e.view('oneline') for e in entity.use_email))
if getattr(entity, 'postal_address', None):
for postaladdress in entity.postal_address:
self.w(u'<tr><th class="labelCol">%s</th><td>%s</td></tr>' %
(display_name(self.req, 'PostalAddress'),
postaladdress.view('incontext')) )
super(PersonPrimaryView, self).render_entity_attributes(entity)
def summary(self, entity):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment