Commit ccaf86fc authored by's avatar
Browse files


branch : tls-sprint
parent e9ad2724659d
......@@ -8,7 +8,7 @@ __docformat__ = "restructuredtext en"
from cubicweb.entities import AnyEntity, fetch_config
class Transition(AnyEntity):
"""customized class for Transition entities
......@@ -17,7 +17,7 @@ class Transition(AnyEntity):
id = 'Transition'
fetch_attrs, fetch_order = fetch_config(['name'])
def may_be_passed(self, eid, stateeid):
"""return true if the logged user may pass this transition
......@@ -44,7 +44,7 @@ class Transition(AnyEntity):
def destination(self):
return self.destination_state[0]
def after_deletion_path(self):
"""return (path, parameters) which should be used as redirect
information when this entity is being deleted
......@@ -53,7 +53,7 @@ class Transition(AnyEntity):
return self.transition_of[0].rest_path(), {'vid': 'workflow'}
return super(Transition, self).after_deletion_path()
class State(AnyEntity):
"""customized class for State entities
......@@ -63,7 +63,7 @@ class State(AnyEntity):
id = 'State'
fetch_attrs, fetch_order = fetch_config(['name'])
rest_attr = 'eid'
def transitions(self, entity, desteid=None):
rql = ('Any T,N,DS where S allowed_transition T, S eid %(x)s, '
'T name N, T destination_state DS, '
......@@ -75,7 +75,7 @@ class State(AnyEntity):
for tr in rset.entities():
if tr.may_be_passed(entity.eid, self.eid):
yield tr
def after_deletion_path(self):
"""return (path, parameters) which should be used as redirect
information when this entity is being deleted
......@@ -84,7 +84,7 @@ class State(AnyEntity):
return self.state_of[0].rest_path(), {'vid': 'workflow'}
return super(State, self).after_deletion_path()
class TrInfo(AnyEntity):
"""customized class for Transition information entities
......@@ -97,7 +97,7 @@ class TrInfo(AnyEntity):
def previous_state(self):
return self.from_state and self.from_state[0]
def new_state(self):
return self.to_state[0]
......@@ -13,14 +13,14 @@ class State(MetaEntityType):
description = RichString(fulltextindexed=True, default_format='text/rest',
description=_('semantic description of this state'))
state_of = SubjectRelation('CWEType', cardinality='+*',
description=_('entity types which may use this state'),
constraints=[RQLConstraint('O final FALSE')])
allowed_transition = SubjectRelation('Transition', cardinality='**',
constraints=[RQLConstraint('S state_of ET, O transition_of ET')],
description=_('allowed transitions from this state'))
initial_state = ObjectRelation('CWEType', cardinality='?*',
# S initial_state O, O state_of S
constraints=[RQLConstraint('O state_of S')],
......@@ -43,7 +43,7 @@ class Transition(MetaEntityType):
'This query may use X and U variables '
'that will respectivly represents '
'the current entity and the current user'))
require_group = SubjectRelation('CWGroup', cardinality='**',
description=_('group in which a user should be to be '
'allowed to pass this transition'))
......@@ -78,12 +78,12 @@ class wf_info_for(MetaRelationType):
inlined = True
composite = 'object'
fulltext_container = composite
class state_of(MetaRelationType):
"""link a state to one or more entity type"""
class transition_of(MetaRelationType):
"""link a transition to one or more entity type"""
class initial_state(MetaRelationType):
"""indicate which state should be used by default when an entity using
states is created
......@@ -93,7 +93,7 @@ class initial_state(MetaRelationType):
class destination_state(MetaRelationType):
"""destination state of a transition"""
inlined = True
class allowed_transition(MetaRelationType):
"""allowed transition from this state"""
......@@ -102,7 +102,7 @@ class in_state(UserRelationType):
meta = True
# not inlined intentionnaly since when using ldap sources, user'state
# has to be stored outside the CWUser table
# add/delete perms given to managers/users, after what most of the job
# is done by workflow enforcment
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