diff -r fbfab570a276 -r 1cba3393ba01 schemas/workflow.py --- a/schemas/workflow.py Mon Jun 22 14:20:46 2009 +0200 +++ b/schemas/workflow.py Tue Jun 23 13:31:16 2009 +0200 @@ -5,11 +5,20 @@ :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses """ +__docformat__ = "restructuredtext en" +_ = unicode -class State(MetaEntityType): +from yams.buildobjs import (EntityType, RelationType, SubjectRelation, + ObjectRelation, String) +from cubicweb.schema import RichString, RQLConstraint +from cubicweb.schemas import META_ETYPE_PERMS, META_RTYPE_PERMS + +class State(EntityType): """used to associate simple states to an entity type and/or to define workflows """ + permissions = META_ETYPE_PERMS + name = String(required=True, indexed=True, internationalizable=True, maxsize=256) description = RichString(fulltextindexed=True, default_format='text/rest', @@ -28,15 +37,15 @@ description=_('initial state for entities of this type')) -class Transition(MetaEntityType): +class Transition(EntityType): """use to define a transition from one or multiple states to a destination states in workflow's definitions. """ + permissions = META_ETYPE_PERMS + name = String(required=True, indexed=True, internationalizable=True, maxsize=256) - description_format = String(meta=True, internationalizable=True, maxsize=50, - default='text/rest', constraints=[format_constraint]) - description = String(fulltextindexed=True, + description = RichString(fulltextindexed=True, description=_('semantic description of this transition')) condition = SubjectRelation('RQLExpression', cardinality='*?', composite='subject', description=_('a RQL expression which should return some results, ' @@ -56,20 +65,22 @@ description=_('destination state for this transition')) -class TrInfo(MetaEntityType): +class TrInfo(EntityType): + permissions = META_ETYPE_PERMS + from_state = SubjectRelation('State', cardinality='?*') to_state = SubjectRelation('State', cardinality='1*') - comment_format = String(meta=True, internationalizable=True, maxsize=50, - default='text/rest', constraints=[format_constraint]) - comment = String(fulltextindexed=True) + comment = RichString(fulltextindexed=True) # get actor and date time using owned_by and creation_date -class from_state(MetaRelationType): +class from_state(RelationType): + permissions = META_RTYPE_PERMS inlined = True -class to_state(MetaRelationType): +class to_state(RelationType): + permissions = META_RTYPE_PERMS inlined = True -class wf_info_for(MetaRelationType): +class wf_info_for(RelationType): """link a transition information to its object""" permissions = { 'read': ('managers', 'users', 'guests',),# RRQLExpression('U has_read_permission O')), @@ -80,30 +91,39 @@ composite = 'object' fulltext_container = composite -class state_of(MetaRelationType): +class state_of(RelationType): """link a state to one or more entity type""" -class transition_of(MetaRelationType): + permissions = META_RTYPE_PERMS +class transition_of(RelationType): """link a transition to one or more entity type""" + permissions = META_RTYPE_PERMS -class initial_state(MetaRelationType): +class initial_state(RelationType): """indicate which state should be used by default when an entity using states is created """ - inlined = True - -class destination_state(MetaRelationType): - """destination state of a transition""" + permissions = META_RTYPE_PERMS inlined = True -class allowed_transition(MetaRelationType): - """allowed transition from this state""" +class destination_state(RelationType): + """destination state of a transition""" + permissions = META_RTYPE_PERMS + inlined = True -class in_state(UserRelationType): +class allowed_transition(RelationType): + """allowed transition from this state""" + permissions = META_RTYPE_PERMS + +class in_state(RelationType): """indicate the current state of an entity""" - 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 + permissions = { + 'read': ('managers', 'users', 'guests',), + 'add': ('managers', 'users',), # XXX has_update_perm + 'delete': ('managers', 'users',), + }