# HG changeset patch # User Sylvain Thénault # Date 1250836937 -7200 # Node ID 77622caef9bd22c53220013f98dde3652e2b3c68 # Parent 77ebdbe93cf83316c8aabf88118d10c5fe9852ca [schema] default_workflow_of more naturally expressed as default_workflow diff -r 77ebdbe93cf8 -r 77622caef9bd entities/wfobjs.py --- a/entities/wfobjs.py Fri Aug 21 08:31:25 2009 +0200 +++ b/entities/wfobjs.py Fri Aug 21 08:42:17 2009 +0200 @@ -29,7 +29,8 @@ """return True if this workflow is the default workflow for the given entity type """ - return any(et for et in self.default_workflow_of if et.name == etype) + return any(et for et in self.reverse_default_workflow + if et.name == etype) def after_deletion_path(self): """return (path, parameters) which should be used as redirect diff -r 77ebdbe93cf8 -r 77622caef9bd schemas/workflow.py --- a/schemas/workflow.py Fri Aug 21 08:31:25 2009 +0200 +++ b/schemas/workflow.py Fri Aug 21 08:42:17 2009 +0200 @@ -26,16 +26,22 @@ description=_('entity types which may use this workflow'), constraints=[RQLConstraint('O final FALSE')]) - default_workflow_of = SubjectRelation('CWEType', cardinality='*?', - description=_('which entity types use this workflow by default'), - constraints=[RQLConstraint('O final FALSE')]) - initial_state = SubjectRelation('State', cardinality='?*', # S initial_state O, O state_of S constraints=[RQLConstraint('O state_of S')], description=_('initial state for this workflow')) +class default_workflow(RelationType): + """default workflow for this entity types""" + permissions = META_RTYPE_PERMS + + subject = 'CWEType' + object = 'Workflow' + cardinality = '?*' + constraints = [RQLConstraint('S final FALSE, O workflow_of S')] + + class State(EntityType): """used to associate simple states to an entity type and/or to define workflows diff -r 77ebdbe93cf8 -r 77622caef9bd server/migractions.py --- a/server/migractions.py Fri Aug 21 08:31:25 2009 +0200 +++ b/server/migractions.py Fri Aug 21 08:42:17 2009 +0200 @@ -923,7 +923,7 @@ {'x': wf.eid, 'et': etype}, 'x') assert rset, 'unexistant entity type %s' % etype if default: - rset = self.rqlexec('SET X default_workflow_of ET ' + rset = self.rqlexec('SET ET default_workflow X ' 'WHERE X eid %(x)s, ET name %(et)s', {'x': wf.eid, 'et': etype}, 'x') if commit: diff -r 77ebdbe93cf8 -r 77622caef9bd server/test/unittest_migractions.py --- a/server/test/unittest_migractions.py Fri Aug 21 08:31:25 2009 +0200 +++ b/server/test/unittest_migractions.py Fri Aug 21 08:42:17 2009 +0200 @@ -111,7 +111,7 @@ s1 = self.mh.rqlexec('Any N WHERE WF workflow_of ET, ET name "%s", WF name N' % etype)[0][0] self.assertEquals(s1, "foo") - s1 = self.mh.rqlexec('Any N WHERE WF default_workflow_of ET, ET name "%s", WF name N' % + s1 = self.mh.rqlexec('Any N WHERE ET default_workflow WF, ET name "%s", WF name N' % etype)[0][0] self.assertEquals(s1, "foo") diff -r 77ebdbe93cf8 -r 77622caef9bd test/unittest_schema.py --- a/test/unittest_schema.py Fri Aug 21 08:31:25 2009 +0200 +++ b/test/unittest_schema.py Fri Aug 21 08:42:17 2009 +0200 @@ -166,7 +166,7 @@ 'composite', 'condition', 'connait', 'constrained_by', 'content', 'content_format', 'created_by', 'creation_date', 'cstrtype', 'custom_workflow', 'cwuri', - 'data', 'data_encoding', 'data_format', 'default_workflow_of', 'defaultval', 'delete_permission', + 'data', 'data_encoding', 'data_format', 'default_workflow', 'defaultval', 'delete_permission', 'description', 'description_format', 'destination_state', 'ecrit_par', 'eid', 'evaluee', 'expression', 'exprtype',