How to use the workflows.models.State.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 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 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)
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)
github unistra / django-workflow-activity / tests / tests.py View on Github external
create_workflow(self)
        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)