schema.py 1.11 KB
Newer Older
Nicolas Chauvat's avatar
Nicolas Chauvat committed
1
from cubicweb.schema import format_constraint
Nicolas Chauvat's avatar
Nicolas Chauvat committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24


class Person(EntityType):
    """a physical person"""
    surname   = String(required=True, fulltextindexed=True, indexed=True, maxsize=64)
    firstname = String(fulltextindexed=True, maxsize=64)
    civility  = String(required=True, internationalizable=True,
                       vocabulary=(_('Mr'), _('Ms'), _('Mrs')),
                       default='Mr')
    
    description_format = String(meta=True, internationalizable=True, maxsize=50,
                                default='text/rest', constraints=[format_constraint])
    description        = String(fulltextindexed=True)

    if 'PhoneNumber' in defined_types: # from addressbook package
        phone         = SubjectRelation('PhoneNumber', composite='subject')

    use_email     = SubjectRelation('EmailAddress', cardinality='*1', composite='subject')
    # allowing an email to be the primary email of multiple persons is necessary for
    # test at least :-/
    primary_email = SubjectRelation('EmailAddress', cardinality='??',
                                    constraints= [RQLConstraint('S use_email O')])