server/test/data/schema/Affaire.py
author sylvain.thenault@logilab.fr
Fri, 17 Apr 2009 16:55:37 +0200
branchtls-sprint
changeset 1398 5fe84a5f7035
parent 629 59b6542f5729
child 1802 d628defebc17
permissions -rw-r--r--
rename internal entity types to have CW prefix instead of E

from cubicweb.schema import format_constraint

class Affaire(WorkflowableEntityType):
    permissions = {
        'read':   ('managers', 
                   ERQLExpression('X owned_by U'), ERQLExpression('X concerne S?, S owned_by U')),
        'add':    ('managers', ERQLExpression('X concerne S, S owned_by U')),
        'update': ('managers', 'owners', ERQLExpression('X in_state S, S name in ("pitetre", "en cours")')),
        'delete': ('managers', 'owners', ERQLExpression('X concerne S, S owned_by U')),
        }
    
    ref = String(fulltextindexed=True, indexed=True,
                 constraints=[SizeConstraint(16)])
    sujet = String(fulltextindexed=True,
                   constraints=[SizeConstraint(256)])
    descr_format = String(meta=True, internationalizable=True,
                                default='text/rest', constraints=[format_constraint])
    descr = String(fulltextindexed=True,
                   description=_('more detailed description'))

    duration = Int()
    invoiced = Int()

    depends_on = SubjectRelation('Affaire')
    require_permission = SubjectRelation('CWPermission')
    
class concerne(RelationType):
    permissions = {
        'read':   ('managers', 'users', 'guests'),
        'add':    ('managers', RRQLExpression('U has_update_permission S')),
        'delete': ('managers', RRQLExpression('O owned_by U')),
        }