Commit 170ba8d3 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

nicer primary view, uicfg tweaks

parent 46d481824b6b
......@@ -14,47 +14,46 @@ from cubicweb.web import uicfg, action
from cubicweb.web.views import baseviews, primary, vcard
from cubicweb.web.facet import AttributeFacet
for attr in ('civility', 'description', 'firstname', 'surname'):
uicfg.primaryview_section.tag_attribute(('Person', attr), 'hidden')
for rtype in ('phone', 'use_email', 'primary_email'):
uicfg.primaryview_section.tag_subject_of(('Person', rtype, '*'), 'hidden')
_pvs =uicfg.primaryview_section
_pvdc = uicfg.primaryview_display_ctrl
for attr in ('civility', 'firstname', 'surname'):
_pvs.tag_attribute(('Person', attr), 'hidden')
for rtype in ('use_email', 'primary_email',
'phone', 'im_address', 'postal_address'):
_pvs.tag_subject_of(('Person', rtype, '*'), 'hidden')
_pvdc.tag_attribute(('Person', 'description'), {'showlabel': False,
'order': 0})
_afs = uicfg.autoform_section
_afs.tag_subject_of(('Person', 'phone', '*'), 'main', 'inlined')
_afs.tag_subject_of(('Person', 'postal_address', '*'), 'main', 'inlined')
_afs.tag_subject_of(('Person', 'im_address', '*'), 'main', 'inlined')
uicfg.autoform_section.tag_subject_of(('Person', 'phone', '*'), 'main', 'inlined')
uicfg.autoform_section.tag_subject_of(('Person', 'postal_address', '*'), 'main', 'inlined')
class PersonPrimaryView(primary.PrimaryView):
__select__ = implements('Person')
attr_table_relations = [('phone', ', '.join),
('use_email', ', '.join),
('im_address', ', '.join),
('postal_address', '<hr/>\n'.join),
]
def render_entity_title(self, entity):
self.w(u'<h1>%s</h1>' % xml_escape(entity.name(civility=True)))
def render_entity_attributes(self, entity):
if getattr(entity, 'phone', None):
self.field('phone', ', '.join(xml_escape(e.view('text'))
for e in entity.phone))
if entity.use_email:
self.field('use_email',
', '.join(e.view('oneline') for e in entity.use_email))
if getattr(entity, 'postal_address', None):
self.w(u"<table>")
for postaladdress in entity.postal_address:
self.w(u'<tr><th class="labelCol">%s</th><td>%s</td></tr>' %
(display_name(self._cw, 'PostalAddress'),
postaladdress.view('incontext')) )
self.w(u"</table>")
if getattr(entity, 'im_address', None):
self.w(u"<table>")
for imaddress in entity.im_address:
self.w(u'<tr><th class="labelCol">%s</th><td>%s</td></tr>' %
(display_name(self._cw, 'IMAddress'),
imaddress.view('incontext')) )
self.w(u"</table>")
super(PersonPrimaryView, self).render_entity_attributes(entity)
def summary(self, entity):
return entity.view('reledit', rtype='description')
hascontent = False
for rel, join in self.attr_table_relations:
related = getattr(entity, rel, None)
if related:
if not hascontent:
self.w(u"<table>")
hascontent = True
self.field(rel, join(e.view('incontext') for e in related), table=True)
if hascontent:
self.w(u"</table>")
class PersonTextView(baseviews.TextView):
......
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