schemas/workflow.py
branchstable
changeset 3966 f742c525b7b4
parent 3961 d1cbf77db999
child 3983 e2dc12753436
equal deleted inserted replaced
3965:94f95928f5ae 3966:f742c525b7b4
    46     workflows
    46     workflows
    47     """
    47     """
    48     permissions = META_ETYPE_PERMS
    48     permissions = META_ETYPE_PERMS
    49 
    49 
    50     name = String(required=True, indexed=True, internationalizable=True,
    50     name = String(required=True, indexed=True, internationalizable=True,
    51                   maxsize=256)
    51                   maxsize=256,
       
    52                   constraints=[RQLUniqueConstraint('S name N, S state_of WF, Y state_of WF, Y name N', 'Y',
       
    53                                                    _('workflow already have a state of that name'))])
    52     description = RichString(fulltextindexed=True, default_format='text/rest',
    54     description = RichString(fulltextindexed=True, default_format='text/rest',
    53                              description=_('semantic description of this state'))
    55                              description=_('semantic description of this state'))
    54 
    56 
    55     # XXX should be on BaseTransition w/ AND/OR selectors when we will
    57     # XXX should be on BaseTransition w/ AND/OR selectors when we will
    56     # implements #345274
    58     # implements #345274
    57     allowed_transition = SubjectRelation('BaseTransition', cardinality='**',
    59     allowed_transition = SubjectRelation('BaseTransition', cardinality='**',
    58                                          constraints=[RQLConstraint('S state_of WF, O transition_of WF')],
    60                                          constraints=[RQLConstraint('S state_of WF, O transition_of WF')],
    59                                          description=_('allowed transitions from this state'))
    61                                          description=_('allowed transitions from this state'))
    60     state_of = SubjectRelation('Workflow', cardinality='1*', composite='object',
    62     state_of = SubjectRelation('Workflow', cardinality='1*', composite='object',
    61                                description=_('workflow to which this state belongs'),
    63                                description=_('workflow to which this state belongs'),
    62                                constraints=[RQLUniqueConstraint('S name N, Y state_of O, Y name N', 'Y')])
    64                                constraints=[RQLUniqueConstraint('S name N, Y state_of O, Y name N', 'Y',
       
    65                                                                 _('workflow already have a state of that name'))])
    63 
    66 
    64 
    67 
    65 class BaseTransition(EntityType):
    68 class BaseTransition(EntityType):
    66     """abstract base class for transitions"""
    69     """abstract base class for transitions"""
    67     permissions = META_ETYPE_PERMS
    70     permissions = META_ETYPE_PERMS
    68 
    71 
    69     name = String(required=True, indexed=True, internationalizable=True,
    72     name = String(required=True, indexed=True, internationalizable=True,
    70                   maxsize=256)
    73                   maxsize=256,
       
    74                   constraints=[RQLUniqueConstraint('S name N, S transition_of WF, Y transition_of WF, Y name N', 'Y',
       
    75                                                    _('workflow already have a transition of that name'))])
    71     type = String(vocabulary=(_('normal'), _('auto')), default='normal')
    76     type = String(vocabulary=(_('normal'), _('auto')), default='normal')
    72     description = RichString(fulltextindexed=True,
    77     description = RichString(fulltextindexed=True,
    73                          description=_('semantic description of this transition'))
    78                          description=_('semantic description of this transition'))
    74     condition = SubjectRelation('RQLExpression', cardinality='*?', composite='subject',
    79     condition = SubjectRelation('RQLExpression', cardinality='*?', composite='subject',
    75                                 description=_('a RQL expression which should return some results, '
    80                                 description=_('a RQL expression which should return some results, '
    81     require_group = SubjectRelation('CWGroup', cardinality='**',
    86     require_group = SubjectRelation('CWGroup', cardinality='**',
    82                                     description=_('group in which a user should be to be '
    87                                     description=_('group in which a user should be to be '
    83                                                   'allowed to pass this transition'))
    88                                                   'allowed to pass this transition'))
    84     transition_of = SubjectRelation('Workflow', cardinality='1*', composite='object',
    89     transition_of = SubjectRelation('Workflow', cardinality='1*', composite='object',
    85                                     description=_('workflow to which this transition belongs'),
    90                                     description=_('workflow to which this transition belongs'),
    86                                     constraints=[RQLUniqueConstraint('S name N, Y transition_of O, Y name N', 'Y')])
    91                                     constraints=[RQLUniqueConstraint('S name N, Y transition_of O, Y name N', 'Y',
       
    92                                                                      _('workflow already have a state of that name'))])
    87 
    93 
    88 
    94 
    89 class Transition(BaseTransition):
    95 class Transition(BaseTransition):
    90     """use to define a transition from one or multiple states to a destination
    96     """use to define a transition from one or multiple states to a destination
    91     states in workflow's definitions.
    97     states in workflow's definitions.