Commit d3607d4a authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[schema] default_workflow_of more naturally expressed as default_workflow

--HG--
branch : 3.5
parent 77ebdbe93cf8
......@@ -29,7 +29,8 @@ class Workflow(AnyEntity):
"""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
......
......@@ -26,16 +26,22 @@ class Workflow(EntityType):
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
......
......@@ -923,7 +923,7 @@ class ServerMigrationHelper(MigrationHelper):
{'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:
......
......@@ -111,7 +111,7 @@ class MigrationCommandsTC(RepositoryBasedTC):
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")
......
......@@ -166,7 +166,7 @@ class SchemaReaderClassTest(TestCase):
'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',
......
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