How to use the workflows.models.Transition.objects.create function in workflows

To help you get started, we’ve selected a few workflows examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github unistra / django-workflow-activity / tests / tests.py View on Github external
self.private = State.objects.create(name='Private', workflow=self.w)
        self.public = State.objects.create(name='Public', workflow=self.w)

        # two states with no transition -> ending states
        self.assertListEqual(list(get_ending_states(self.w)), [self.private,
            self.public])

        self.make_public = Transition.objects.create(name='Make public',
                workflow=self.w, destination=self.public)
        self.private.transitions.add(self.make_public)
        
        # branching a transition on a state
        self.assertListEqual(list(get_ending_states(self.w)), [self.public])

        self.make_private = Transition.objects.create(name='Make private',
                workflow=self.w, destination=self.private)
        self.public.transitions.add(self.make_private)

        # cycle transitions -> no ending states
        self.assertListEqual(list(get_ending_states(self.w)), [])
github diefenbach / django-workflows / workflows / tests.py View on Github external
def create_workflow(self):
    self.w = Workflow.objects.create(name="Standard")

    self.private = State.objects.create(name="Private", workflow= self.w)
    self.public = State.objects.create(name="Public", workflow= self.w)

    self.make_public = Transition.objects.create(name="Make public", workflow=self.w, destination = self.public)
    self.make_private = Transition.objects.create(name="Make private", workflow=self.w, destination = self.private)

    self.private.transitions.add(self.make_public)
    self.public.transitions.add(self.make_private)

    self.w.initial_state = self.private
    self.w.save()
github unistra / django-workflow-activity / tests / tests.py View on Github external
def test_get_ending_states(self):
        """
        """

        # no defined state for workflow
        self.w = Workflow.objects.create(name='Standard')
        self.assertListEqual(list(get_ending_states(self.w)), [])

        self.private = State.objects.create(name='Private', workflow=self.w)
        self.public = State.objects.create(name='Public', workflow=self.w)

        # two states with no transition -> ending states
        self.assertListEqual(list(get_ending_states(self.w)), [self.private,
            self.public])

        self.make_public = Transition.objects.create(name='Make public',
                workflow=self.w, destination=self.public)
        self.private.transitions.add(self.make_public)
        
        # branching a transition on a state
        self.assertListEqual(list(get_ending_states(self.w)), [self.public])

        self.make_private = Transition.objects.create(name='Make private',
                workflow=self.w, destination=self.private)
        self.public.transitions.add(self.make_private)

        # cycle transitions -> no ending states
        self.assertListEqual(list(get_ending_states(self.w)), [])
github unistra / django-workflow-activity / tests / tests.py View on Github external
self.anonymous_user = User.objects.create(username='anonymous_user')
        permissions.utils.add_role(self.anonymous_user, self.anonymous)
        self.test_user = User.objects.create(username='test_user',
            first_name='Test', last_name='User')
        permissions.utils.add_role(self.test_user, self.publisher)

        self.flat_page = FlatPage.objects.create(url='/page-1', title='Page 1',
                initializer=self.test_user)

        # permissions
        self.edit = permissions.utils.register_permission('Edit', 'edit')
        self.view = permissions.utils.register_permission('View', 'view')

        # state, transition
        self.rejected = State.objects.create(name='Rejected', workflow=self.w)
        self.reject = Transition.objects.create(name='Reject',
                workflow=self.w, destination=self.rejected,
                permission=self.edit)
        self.private.transitions.add(self.reject)

        # permissions for the workflow
        WorkflowPermissionRelation.objects.create(workflow=self.w,
                permission=self.edit)
        WorkflowPermissionRelation.objects.create(workflow=self.w,
                permission=self.view)

        # permissions for states
        StatePermissionRelation.objects.create(state=self.public,
                permission=self.view, role=self.publisher)
        StatePermissionRelation.objects.create(state=self.private,
                permission=self.edit, role=self.publisher)
        StatePermissionRelation.objects.create(state=self.private,
github diefenbach / django-workflows / workflows / tests.py View on Github external
def create_workflow(self):
    self.w = Workflow.objects.create(name="Standard")

    self.private = State.objects.create(name="Private", workflow= self.w)
    self.public = State.objects.create(name="Public", workflow= self.w)

    self.make_public = Transition.objects.create(name="Make public", workflow=self.w, destination = self.public)
    self.make_private = Transition.objects.create(name="Make private", workflow=self.w, destination = self.private)

    self.private.transitions.add(self.make_public)
    self.public.transitions.add(self.make_private)

    self.w.initial_state = self.private
    self.w.save()
github unistra / django-workflow-activity / tests / tests.py View on Github external
self.user = User.objects.create(username='test_user',
            first_name='Test', last_name='User')
        self.first_page = FlatPage.objects.create(url='/page-1',
                title='Page 1', initializer=self.user)
        self.second_page = FlatPage.objects.create(url='/page-2',
                title='Page 2', initializer=self.user)
        self.third_page = FlatPage.objects.create(url='/page-3',
                title='Page 3', initializer=self.user)
        self.fourth_page = FlatPage.objects.create(url='/page-4',
                title='Page 4', initializer=self.user)
        self.fifth_page = FlatPage.objects.create(url='/page-5',
                title='Page 5', initializer=self.user)
        
        # new transition and state
        self.rejected = State.objects.create(name='Rejected', workflow=self.w)
        self.reject = Transition.objects.create(name='Reject',
                workflow=self.w, destination=self.rejected)
        self.private.transitions.add(self.reject)
github diefenbach / django-workflows / workflows / tests.py View on Github external
workflows.utils.do_transition(self.page_1, self.make_public, self.user)

        state = workflows.utils.get_state(self.page_1)
        self.assertEqual(state.name, self.public.name)

        # by name
        workflows.utils.do_transition(self.page_1, "Make private", self.user)

        state = workflows.utils.get_state(self.page_1)
        self.assertEqual(state.name, self.private.name)

        # name which does not exist
        result = workflows.utils.do_transition(self.page_1, "Make pending", self.user)
        self.assertEqual(result, False)

        wrong = Transition.objects.create(name="Wrong", workflow=self.w, destination = self.public)

        # name which does not exist
        result = workflows.utils.do_transition(self.page_1, wrong, self.user)
        self.assertEqual(result, False)