--- a/entities/wfobjs.py Thu Apr 30 10:33:33 2009 +0200
+++ b/entities/wfobjs.py Thu Apr 30 10:33:49 2009 +0200
@@ -8,7 +8,7 @@
from cubicweb.entities import AnyEntity, fetch_config
-
+
class Transition(AnyEntity):
"""customized class for Transition entities
@@ -17,7 +17,7 @@
"""
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
@property
def previous_state(self):
return self.from_state and self.from_state[0]
-
+
@property
def new_state(self):
return self.to_state[0]
--- a/schemas/workflow.py Thu Apr 30 10:33:33 2009 +0200
+++ b/schemas/workflow.py Thu Apr 30 10:33:49 2009 +0200
@@ -13,14 +13,14 @@
maxsize=256)
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 @@
'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 @@
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 destination_state(MetaRelationType):
"""destination state of a transition"""
inlined = True
-
+
class allowed_transition(MetaRelationType):
"""allowed transition from this state"""
@@ -102,7 +102,7 @@
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
-
+