This commit is contained in:
Norman Jäckel 2013-06-02 23:12:00 +02:00
parent 63840df7b5
commit a575a7a8c6
2 changed files with 72 additions and 69 deletions

View File

@ -136,71 +136,73 @@ def create_builtin_workflows(sender, **kwargs):
""" """
Creates a simple and a complex workflow. Creates a simple and a complex workflow.
""" """
workflow_1 = Workflow.objects.create(name=ugettext_noop('Simple Workflow')) workflow_1, created = Workflow.objects.get_or_create(name=ugettext_noop('Simple Workflow'))
state_1_1 = State.objects.create(name=ugettext_noop('submitted'), if created:
workflow=workflow_1, state_1_1 = State.objects.create(name=ugettext_noop('submitted'),
allow_create_poll=True, workflow=workflow_1,
allow_support=True, allow_create_poll=True,
allow_submitter_edit=True) allow_support=True,
state_1_2 = State.objects.create(name=ugettext_noop('accepted'), allow_submitter_edit=True)
workflow=workflow_1, state_1_2 = State.objects.create(name=ugettext_noop('accepted'),
action_word=ugettext_noop('Accept')) workflow=workflow_1,
state_1_3 = State.objects.create(name=ugettext_noop('rejected'), action_word=ugettext_noop('Accept'))
workflow=workflow_1, state_1_3 = State.objects.create(name=ugettext_noop('rejected'),
action_word=ugettext_noop('Reject')) workflow=workflow_1,
state_1_4 = State.objects.create(name=ugettext_noop('not decided'), action_word=ugettext_noop('Reject'))
workflow=workflow_1, state_1_4 = State.objects.create(name=ugettext_noop('not decided'),
action_word=ugettext_noop('Do not decide')) workflow=workflow_1,
state_1_1.next_states.add(state_1_2, state_1_3, state_1_4) action_word=ugettext_noop('Do not decide'))
workflow_1.first_state = state_1_1 state_1_1.next_states.add(state_1_2, state_1_3, state_1_4)
workflow_1.save() workflow_1.first_state = state_1_1
workflow_1.save()
workflow_2 = Workflow.objects.create(name=ugettext_noop('Complex Workflow')) workflow_2, created = Workflow.objects.get_or_create(name=ugettext_noop('Complex Workflow'))
state_2_1 = State.objects.create(name=ugettext_noop('published'), if created:
workflow=workflow_2, state_2_1 = State.objects.create(name=ugettext_noop('published'),
allow_support=True, workflow=workflow_2,
allow_submitter_edit=True, allow_support=True,
dont_set_identifier=True) allow_submitter_edit=True,
state_2_2 = State.objects.create(name=ugettext_noop('permitted'), dont_set_identifier=True)
workflow=workflow_2, state_2_2 = State.objects.create(name=ugettext_noop('permitted'),
action_word=ugettext_noop('Permit'), workflow=workflow_2,
allow_create_poll=True, action_word=ugettext_noop('Permit'),
allow_submitter_edit=True, allow_create_poll=True,
versioning=True, allow_submitter_edit=True,
leave_old_version_active=True) versioning=True,
state_2_3 = State.objects.create(name=ugettext_noop('accepted'), leave_old_version_active=True)
workflow=workflow_2, state_2_3 = State.objects.create(name=ugettext_noop('accepted'),
action_word=ugettext_noop('Accept'), workflow=workflow_2,
versioning=True) action_word=ugettext_noop('Accept'),
state_2_4 = State.objects.create(name=ugettext_noop('rejected'), versioning=True)
workflow=workflow_2, state_2_4 = State.objects.create(name=ugettext_noop('rejected'),
action_word=ugettext_noop('Reject'), workflow=workflow_2,
versioning=True) action_word=ugettext_noop('Reject'),
state_2_5 = State.objects.create(name=ugettext_noop('withdrawed'), versioning=True)
workflow=workflow_2, state_2_5 = State.objects.create(name=ugettext_noop('withdrawed'),
action_word=ugettext_noop('Withdraw'), workflow=workflow_2,
versioning=True) action_word=ugettext_noop('Withdraw'),
state_2_6 = State.objects.create(name=ugettext_noop('adjourned'), versioning=True)
workflow=workflow_2, state_2_6 = State.objects.create(name=ugettext_noop('adjourned'),
action_word=ugettext_noop('Adjourn'), workflow=workflow_2,
versioning=True) action_word=ugettext_noop('Adjourn'),
state_2_7 = State.objects.create(name=ugettext_noop('not concerned'), versioning=True)
workflow=workflow_2, state_2_7 = State.objects.create(name=ugettext_noop('not concerned'),
action_word=ugettext_noop('Do not concern'), workflow=workflow_2,
versioning=True) action_word=ugettext_noop('Do not concern'),
state_2_8 = State.objects.create(name=ugettext_noop('commited a bill'), versioning=True)
workflow=workflow_2, state_2_8 = State.objects.create(name=ugettext_noop('commited a bill'),
action_word=ugettext_noop('Commit a bill'), workflow=workflow_2,
versioning=True) action_word=ugettext_noop('Commit a bill'),
state_2_9 = State.objects.create(name=ugettext_noop('needs review'), versioning=True)
workflow=workflow_2, state_2_9 = State.objects.create(name=ugettext_noop('needs review'),
action_word=ugettext_noop('Needs review'), workflow=workflow_2,
versioning=True) action_word=ugettext_noop('Needs review'),
state_2_10 = State.objects.create(name=ugettext_noop('rejected (not authorized)'), versioning=True)
workflow=workflow_2, state_2_10 = State.objects.create(name=ugettext_noop('rejected (not authorized)'),
action_word=ugettext_noop('Reject (not authorized)'), workflow=workflow_2,
versioning=True) action_word=ugettext_noop('Reject (not authorized)'),
state_2_1.next_states.add(state_2_2, state_2_5, state_2_10) versioning=True)
state_2_2.next_states.add(state_2_3, state_2_4, state_2_5, state_2_6, state_2_7, state_2_8, state_2_9) state_2_1.next_states.add(state_2_2, state_2_5, state_2_10)
workflow_2.first_state = state_2_1 state_2_2.next_states.add(state_2_3, state_2_4, state_2_5, state_2_6, state_2_7, state_2_8, state_2_9)
workflow_2.save() workflow_2.first_state = state_2_1
workflow_2.save()

View File

@ -68,8 +68,9 @@ def create_builtin_groups(sender, **kwargs):
Creates the builtin groups: Anonymous, Registered, Delegates and Staff. Creates the builtin groups: Anonymous, Registered, Delegates and Staff.
""" """
# Check whether the group pks 1 to 4 are free # Check whether the group pks 1 to 4 are free
for pk in range(1, 5): if Group.objects.filter(pk__in=range(1, 5)).exists():
assert not Group.objects.filter(pk=pk).exists(), 'There should not be any group with pk 1, 2, 3 or 4.' # Do completely nothing if there are already some of our groups in the database.
return
# Anonymous and Registered # Anonymous and Registered
ct_projector = ContentType.objects.get(app_label='projector', model='projectorslide') ct_projector = ContentType.objects.get(app_label='projector', model='projectorslide')