Commit 6c67a899 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

default is now stable

--HG--
branch : stable
......@@ -5,3 +5,7 @@
98757d40e6b96080410b489bcd026ea2b88fb3bd cubicweb-person-version-1_5_0
ac2dbe5928ec7daa1ab60da9d12ff9b539d270e2 cubicweb-person-debian-version-1_5_0-1
5fec8191e5ee481f4c174d3d4600308a62134e98 oldstable
e102d7116b5ac830675c0f42b29e35635464198d cubicweb-person-version-1.6.0
bff981714e2e699742110f5f5f7de4bb6104dd49 cubicweb-person-debian-version-1.6.0-1
c3a38d9bf447f0fc46bf346ee78c0c172c4a3538 cubicweb-person-version-1.7.0
f3092f7f5d195ba54cea8f90a74d32882e599232 cubicweb-person-debian-version-1.7.0-1
......@@ -4,11 +4,11 @@
modname = 'person'
distname = "cubicweb-%s" % modname
numversion = (1, 5, 0)
numversion = (1, 7, 0)
version = '.'.join(str(num) for num in numversion)
license = 'LGPL'
copyright = '''Copyright (c) 2003-2009 LOGILAB S.A. (Paris, FRANCE).
copyright = '''Copyright (c) 2003-2010 LOGILAB S.A. (Paris, FRANCE).
http://www.logilab.fr/ -- mailto:contact@logilab.fr'''
author = "Logilab"
......@@ -16,10 +16,65 @@ author_email = "contact@logilab.fr"
web = 'http://www.cubicweb.org/project/%s' % distname
short_desc = "person component for the CubicWeb framework"
long_desc = """This CubicWeb component models person (firstname, lastname,
email address and optional postal address).
long_desc = """\
Summary
-------
`person` provides person informations :
- firstname
- surname / lastname
- civility
- arbitrary text description
- a relation to an email address (NB, the `EmailAddress` entity is
automatically provided by cubicweb).
If the `addressbook` cube is used, persons will also have *phone* and
*postal_address* relations to store more contact information.
There is a special relation called 'primary_email'. A person can be linked to
multiple email addresses (using the 'use_email' relation). The primary email
must be unique. At the creation of the first email, this relation is
automatically added (though you can change it later, of course).
Recommends
----------
- `addressbook` cube
Usage
-----
In addition of basic entity views, this cube provides :
- *VCardPersonView*, displays a person in the VCard file format
(.. _VCard on wikipedia: http://en.wikipedia.org/wiki/VCard) .
This view creates a file called `vcard.vcf` which can be open in
your addressbook application (Kmail, Thunderbird and so on). In
order to generate this file, you have to access to a specific view
using an url address with `?vid=vcard` suffix.
How to personalize the person primary view in order to add a link
for the vcard ?
.. sourcecode:: python
class PersonalizedPersonPrimaryView(PersonPrimaryView):
def render_entity_attributes(self, entity):
super(PersonalizedPersonPrimaryView, self).render_entity_attributes(entity)
self.w(u'<div><a href="%s">export contact as vcard</a></div>' % entity.absolute_url(vid='vcard'))
This view will not be selected by default. You have to registered
this view or add a selector. For more information, please refer to
XXX in the doc.
- a *civility facet*, this facet (XXX: ref to facet doc) will be shown
if a view displays a result set of at least two Person entities with
different civilities.
CubicWeb is a semantic web application framework, see http://www.cubicweb.org
"""
classifiers = [
......@@ -30,7 +85,7 @@ classifiers = [
]
__depends_cubes__ = {}
__depends__ = {'cubicweb': None}
__depends__ = {'cubicweb': '>= 3.6.0'}
__use__ = ()
__recommend__ = ('addressbook',)
......
cubicweb-person (1.7.0-1) unstable; urgency=low
* new upstream release
-- Sylvain Thénault <sylvain.thenault@logilab.fr> Wed, 27 Jan 2010 12:33:37 +0100
cubicweb-person (1.6.0-1) unstable; urgency=low
* new upstream release
-- Graziella Toutoungis <graziella.toutoungis@logilab.fr> fri, 09 oct 2009 13:10:50 +0200
cubicweb-person (1.5.0-1) unstable; urgency=low
* new upstream release
......
......@@ -11,7 +11,8 @@ Package: cubicweb-person
Architecture: all
Conflicts: erudi-person, erudi-person-server, erudi-person-client, erudi-person-comp
Replaces: erudi-person, erudi-person-server, erudi-person-client, erudi-person-comp
Depends: cubicweb-common (>= 3.2.0)
Depends: cubicweb-common (>= 3.6.0)
Recommends: cubicweb-addressbook
Description: person component for the CubicWeb framework
This CubicWeb component models person (firstname, lastname,
email address and optional postal address).
......
"""entity classes for optional person entities
:organization: Logilab
:copyright: 2003-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:copyright: 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
__docformat__ = "restructuredtext en"
from cubicweb.common.mixins import EmailableMixIn
from cubicweb.mixins import EmailableMixIn
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'')
......
......@@ -11,6 +11,14 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgctxt "inlined:Person.use_email.subject"
msgid "EmailAddress"
msgstr "email address"
msgctxt "inlined:Person.im_address.subject"
msgid "IMAddress"
msgstr "instant messager address"
msgid "Mr"
msgstr "Mr"
......@@ -32,6 +40,14 @@ msgstr "Person"
msgid "Person_plural"
msgstr "Persons"
msgctxt "inlined:Person.phone.subject"
msgid "PhoneNumber"
msgstr "Phone number"
msgctxt "inlined:Person.postal_address.subject"
msgid "PostalAddress"
msgstr "Postal address"
msgid "This Person"
msgstr "This person"
......@@ -44,6 +60,9 @@ msgstr "add person from sender"
msgid "actions_addperson-fromemail_description"
msgstr "add person from sender"
msgid "add Person im_address IMAddress subject"
msgstr "IM address"
msgid "add Person phone PhoneNumber subject"
msgstr "phone number"
......@@ -57,23 +76,51 @@ msgstr "person"
msgid "add Person use_email EmailAddress subject"
msgstr "email address"
msgid "add a Person"
msgstr "add a person"
msgctxt "inlined:Person.use_email.subject"
msgid "add a EmailAddress"
msgstr "add an email address"
msgctxt "inlined:Person.im_address.subject"
msgid "add a IMAddress"
msgstr "add an IM address"
msgctxt "inlined:Person.phone.subject"
msgid "add a PhoneNumber"
msgstr "add a phone number"
msgctxt "inlined:Person.postal_address.subject"
msgid "add a PostalAddress"
msgstr "add a postal address"
# subject and object forms for each relation type
# (no object form for final relation types)
msgid "civility"
msgstr "civility"
msgctxt "Person"
msgid "civility"
msgstr "civility"
msgid "creating EmailAddress (Person %(linkto)s use_email EmailAddress)"
msgstr "email address of %(linkto)s"
msgid "creating IMAddress (Person %(linkto)s im_address IMAddress)"
msgstr "IM address of %(linkto)s"
msgid "creating PhoneNumber (Person %(linkto)s phone PhoneNumber)"
msgstr "phone number of %(linkto)s"
msgid "creating PostalAddress (Person %(linkto)s postal_address PostalAddress)"
msgstr "address of %(linkto)s "
msgctxt "Person"
msgid "description"
msgstr "description"
msgctxt "Person"
msgid "description_format"
msgstr "format"
msgid "emails"
msgstr "emails"
......@@ -81,17 +128,66 @@ msgstr "emails"
msgid "emails sent or received by %s"
msgstr "emails sent or received by %s"
msgid "facets_civility-facet"
msgstr "civility facet"
msgid "facets_civility-facet_description"
msgstr ""
msgctxt "Person"
msgid "firstname"
msgstr "first name"
msgid "im_address"
msgstr "IM address"
msgctxt "Person"
msgid "im_address"
msgstr "IM address"
msgctxt "IMAddress"
msgid "im_address_object"
msgstr "IM address of"
msgid "im_address_object"
msgstr "IM address of"
msgid "phone"
msgstr "phone"
msgctxt "Person"
msgid "phone"
msgstr "phone"
msgctxt "PhoneNumber"
msgid "phone_object"
msgstr "phone of"
msgid "phone_object"
msgstr "phone of"
msgid "postal_address"
msgstr "address"
msgstr "postal address"
msgctxt "Person"
msgid "postal_address"
msgstr "postal address"
msgctxt "PostalAddress"
msgid "postal_address_object"
msgstr "postal address of"
msgid "postal_address_object"
msgstr "address of"
msgid "remove this Person"
msgstr "remove this person"
msgctxt "Person"
msgid "primary_email"
msgstr "primary email"
msgctxt "Person"
msgid "surname"
msgstr "surname"
msgctxt "Person"
msgid "use_email"
msgstr "use email"
......@@ -11,6 +11,14 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgctxt "inlined:Person.use_email.subject"
msgid "EmailAddress"
msgstr "Adresse email"
msgctxt "inlined:Person.im_address.subject"
msgid "IMAddress"
msgstr "Adresse messagerie instantanée"
msgid "Mr"
msgstr "M."
......@@ -32,6 +40,14 @@ msgstr "Personne"
msgid "Person_plural"
msgstr "Personnes"
msgctxt "inlined:Person.phone.subject"
msgid "PhoneNumber"
msgstr "N° de téléphone"
msgctxt "inlined:Person.postal_address.subject"
msgid "PostalAddress"
msgstr "Adresse postale"
msgid "This Person"
msgstr "Cette personne"
......@@ -44,11 +60,14 @@ msgstr "créer personne à partir de l'expéditeur"
msgid "actions_addperson-fromemail_description"
msgstr "créer personne à partir de l'expéditeur"
msgid "add Person im_address IMAddress subject"
msgstr "adresse de messagerie instantanée"
msgid "add Person phone PhoneNumber subject"
msgstr "numéro de téléphone"
msgid "add Person postal_address PostalAddress subject"
msgstr "adresse"
msgstr "adresse postal"
msgid "add Person use_email EmailAddress object"
msgstr "personne"
......@@ -57,23 +76,51 @@ msgstr "personne"
msgid "add Person use_email EmailAddress subject"
msgstr "adresse email"
msgid "add a Person"
msgstr "ajouter une personne"
msgctxt "inlined:Person.use_email.subject"
msgid "add a EmailAddress"
msgstr "ajouter une adresse email"
msgctxt "inlined:Person.im_address.subject"
msgid "add a IMAddress"
msgstr "ajouter une adresse de messagerie instantanée"
msgctxt "inlined:Person.phone.subject"
msgid "add a PhoneNumber"
msgstr "ajouter un n° de téléphone"
msgctxt "inlined:Person.postal_address.subject"
msgid "add a PostalAddress"
msgstr "ajouter une adresse postale"
# subject and object forms for each relation type
# (no object form for final relation types)
msgid "civility"
msgstr "civilité"
msgctxt "Person"
msgid "civility"
msgstr "civilité"
msgid "creating EmailAddress (Person %(linkto)s use_email EmailAddress)"
msgstr "adresse électronique de %(linkto)s"
msgid "creating IMAddress (Person %(linkto)s im_address IMAddress)"
msgstr "adresse de messagerie instantanée de %(linkto)s"
msgid "creating PhoneNumber (Person %(linkto)s phone PhoneNumber)"
msgstr "numéro de téléphone de %(linkto)s"
msgid "creating PostalAddress (Person %(linkto)s postal_address PostalAddress)"
msgstr "adresse de %(linkto)s"
msgctxt "Person"
msgid "description"
msgstr "description"
msgctxt "Person"
msgid "description_format"
msgstr "description format"
msgid "emails"
msgstr "courriels"
......@@ -81,17 +128,66 @@ msgstr "courriels"
msgid "emails sent or received by %s"
msgstr "courriels émis ou reçus par %s"
msgid "facets_civility-facet"
msgstr "facette civilité"
msgid "facets_civility-facet_description"
msgstr ""
msgctxt "Person"
msgid "firstname"
msgstr "prénon"
msgid "im_address"
msgstr "messagerie instantanée"
msgctxt "Person"
msgid "im_address"
msgstr "messagerie instantanée"
msgctxt "IMAddress"
msgid "im_address_object"
msgstr "utilisé par"
msgid "im_address_object"
msgstr "utilisé par"
msgid "phone"
msgstr "téléphone"
msgctxt "Person"
msgid "phone"
msgstr "téléphone"
msgctxt "PhoneNumber"
msgid "phone_object"
msgstr "téléphone de"
msgid "phone_object"
msgstr "téléphone de"
msgid "postal_address"
msgstr "adresse postale"
msgctxt "Person"
msgid "postal_address"
msgstr "adresse"
msgstr "adresse postale"
msgctxt "PostalAddress"
msgid "postal_address_object"
msgstr "adresse de"
msgid "postal_address_object"
msgstr "adresse de"
msgid "remove this Person"
msgstr "supprimer cette personne"
msgctxt "Person"
msgid "primary_email"
msgstr "email principal"
msgctxt "Person"
msgid "surname"
msgstr "nom"
msgctxt "Person"
msgid "use_email"
msgstr "utilise email"
add_relation_definition('Person', 'postal_address', 'PostalAddress')
if 'PostalAddress' in schema:
add_relation_definition('Person', 'postal_address', 'PostalAddress')
if 'IMAddress' in schema:
add_relation_definition('Person', 'im_address', 'IMAddress')
......@@ -25,6 +25,8 @@ class Person(EntityType):
phone = SubjectRelation('PhoneNumber', composite='subject')
if 'PostalAddress' in defined_types:
postal_address = SubjectRelation('PostalAddress', composite='subject')
if 'IMAddress' in defined_types:
im_address = SubjectRelation('IMAddress', composite='subject')
use_email = SubjectRelation('EmailAddress', cardinality='*1', composite='subject')
# allowing an email to be the primary email of multiple persons is necessary for
......
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')
......
"""Specific views for person entities
:organization: Logilab
:copyright: 2003-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:copyright: 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
__docformat__ = "restructuredtext en"
from logilab.mtconverter import xml_escape
from cubicweb.schema import display_name
from cubicweb.selectors import implements, rql_condition
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_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')
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.req, 'PostalAddress'),
postaladdress.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):
__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()
......@@ -105,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')
......@@ -116,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