How to use the workflows.utils.get_state 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 test_state(self):
        """
        """
        result = workflows.utils.get_state(self.user)
        self.assertEqual(result, None)

        workflows.utils.set_workflow(self.user, self.w)
        result = workflows.utils.get_state(self.user)
        self.assertEqual(result, self.w.initial_state)
github diefenbach / django-workflows / workflows / tests.py View on Github external
def test_do_transition(self):
        """
        """
        state = workflows.utils.get_state(self.page_1)
        self.assertEqual(state.name, self.private.name)

        # by transition
        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)
github diefenbach / django-workflows / workflows / tests.py View on Github external
def test_set_initial_state(self):
        """
        """
        state = workflows.utils.get_state(self.page_1)
        self.assertEqual(state.name, self.private.name)

        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)

        workflows.utils.set_initial_state(self.page_1)
        state = workflows.utils.get_state(self.page_1)
        self.assertEqual(state.name, self.private.name)
github diefenbach / django-workflows / workflows / tests.py View on Github external
def test_set_initial_state(self):
        """
        """
        state = workflows.utils.get_state(self.page_1)
        self.assertEqual(state.name, self.private.name)

        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)

        workflows.utils.set_initial_state(self.page_1)
        state = workflows.utils.get_state(self.page_1)
        self.assertEqual(state.name, self.private.name)
github diefenbach / django-workflows / workflows / templatetags / workflows_tags.py View on Github external
def transitions(context, obj):
    """
    """
    request = context.get("request")
    
    return {
        "transitions" : workflows.utils.get_allowed_transitions(obj, request.user),
        "state" : workflows.utils.get_state(obj),
    }
github diefenbach / django-workflows / workflows / __init__.py View on Github external
def get_state(self):
        """Returns the current workflow state of the object.
        """
        return workflows.utils.get_state(self)
github saxix / django-workflows / workflows / templatetags / workflows_tags.py View on Github external
def transitions(context, obj):
    """
    """
    request = context.get("request")
    
    return {
        "transitions" : workflows.utils.get_allowed_transitions(obj, request.user),
        "state" : workflows.utils.get_state(obj),
    }
github unistra / django-workflow-activity / workflow_activity / models.py View on Github external
def state(self):
        """ Get the state in workflow for the instance of the workflow managed
        model

        :return: the state of the managed instance
        :rtype: `workflows.models.State `_
        """
        return get_state(self)