Commit 8f875532 authored by Sandrine Ribeau's avatar Sandrine Ribeau
Browse files

api-update

parent 84380c553af4
......@@ -12,7 +12,7 @@ from cubicweb.entities import AnyEntity, fetch_config
class Person(EmailableMixIn, AnyEntity):
"""customized class for Person entities"""
id = 'Person'
__regid__ = 'Person'
fetch_attrs, fetch_order = fetch_config(['surname', 'firstname'])
rest_attr = 'surname'
skip_copy_for = ('primary_email',)
......@@ -25,7 +25,7 @@ class Person(EmailableMixIn, AnyEntity):
def name(self, civility=False):
if civility and self.civility:
return u'%s %s %s' % (self.req._(self.civility),
return u'%s %s %s' % (self._cw._(self.civility),
self.firstname or u'', self.surname or u'')
return u'%s %s' % (self.firstname or u'', self.surname or u'')
......
from logilab.common.testlib import unittest_main
from cubicweb.devtools.apptest import EnvBasedTC
from cubicweb.devtools.testlib import CubicWebTC
class PersonTC(EnvBasedTC):
class PersonTC(CubicWebTC):
def setup_database(self):
self.add_entity('Person', firstname=u'adrien', surname=u'di mascio')
self.request().create_entity('Person', firstname=u'adrien', surname=u'di mascio')
def test_dc_title(self):
e = self.entity('Any X WHERE X is Person')
......
......@@ -18,8 +18,8 @@ for attr in ('civility', 'description', 'firstname', 'surname'):
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)
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')
......@@ -39,7 +39,7 @@ class PersonPrimaryView(primary.PrimaryView):
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.req, 'PostalAddress'),
(display_name(self._cw, 'PostalAddress'),
postaladdress.view('incontext')) )
self.w(u"</table>")
......@@ -47,7 +47,7 @@ class PersonPrimaryView(primary.PrimaryView):
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.req, 'IMAddress'),
(display_name(self._cw, 'IMAddress'),
imaddress.view('incontext')) )
self.w(u"</table>")
super(PersonPrimaryView, self).render_entity_attributes(entity)
......@@ -60,20 +60,20 @@ class PersonTextView(baseviews.TextView):
__select__ = implements('Person')
def cell_call(self, row, col):
entity = self.entity(row, col)
entity = self.cw_rset.get_entity(row, col)
self.w(entity.name())
class PersonEmailView(baseviews.EntityView):
"""display emails sent or received by one of this person's addresses"""
id = 'emails'
__regid__ = 'emails'
__select__ = implements('Person')
title = _('emails')
def cell_call(self, row, col=0):
entity = self.entity(row, col)
entity = self.cw_rset.get_entity(row, col)
self.w(u'<h3>')
self.w(self.req._('emails sent or received by %s')
self.w(self._cw._('emails sent or received by %s')
% xml_escape(entity.dc_title()))
self.w(u'</h3>')
done = set()
......@@ -113,7 +113,7 @@ class VCardPersonView(vcard.VCardCWUserView):
## actions ####################################################################
class AddPersonFromEmailAction(action.LinkToEntityAction):
id = 'addperson-fromemail'
__regid__ = 'addperson-fromemail'
__select__ = implements('EmailAddress') & rql_condition('NOT P use_email X')
title = _('add Person use_email EmailAddress object')
......@@ -124,6 +124,6 @@ class AddPersonFromEmailAction(action.LinkToEntityAction):
## facets #####################################################################
class CivilityFacet(AttributeFacet):
id = 'civility-facet'
__regid__ = 'civility-facet'
__select__ = implements('Person')
rtype = 'civility'
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