How to use workflows - 10 common examples

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_unicode(self):
        """
        """
        # WorkflowObjectRelation
        workflows.utils.set_workflow(self.page_1, self.w)
        wor = WorkflowObjectRelation.objects.filter()[0]
        self.assertEqual(wor.__unicode__(), "flat page 1 - Standard")

        # StateObjectRelation
        workflows.utils.set_state(self.page_1, self.public)
        sor = StateObjectRelation.objects.filter()[0]
        self.assertEqual(sor.__unicode__(), "flat page 1 - Public")

        # WorkflowModelRelation
        ctype = ContentType.objects.get_for_model(self.page_1)
        workflows.utils.set_workflow(ctype, self.w)
        wmr = WorkflowModelRelation.objects.filter()[0]
        self.assertEqual(wmr.__unicode__(), "flat page - Standard")

        # WorkflowPermissionRelation
        self.view = permissions.utils.register_permission("View", "view")
        wpr = WorkflowPermissionRelation.objects.create(workflow=self.w, permission=self.view)
        self.assertEqual(wpr.__unicode__(), "Standard View")

        # StatePermissionRelation
        self.owner = permissions.utils.register_role("Owner")
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_get_objects_for_workflow_2(self):
        """Workflow is added to content type.
        """
        result = workflows.utils.get_objects_for_workflow(self.w)
        self.assertEqual(result, [])

        ctype = ContentType.objects.get_for_model(self.user)
        workflows.utils.set_workflow(ctype, self.w)
        result = workflows.utils.get_objects_for_workflow(self.w)
        self.assertEqual(result, [self.user])
github diefenbach / django-workflows / workflows / tests.py View on Github external
# Add all permissions which are managed by the workflow
        wpr = WorkflowPermissionRelation.objects.create(workflow=self.w, permission=self.view)
        wpr = WorkflowPermissionRelation.objects.create(workflow=self.w, permission=self.edit)

        # Add permissions for single states
        spr = StatePermissionRelation.objects.create(state=self.public, permission=self.view, role=self.owner)
        spr = StatePermissionRelation.objects.create(state=self.private, permission=self.view, role=self.owner)
        spr = StatePermissionRelation.objects.create(state=self.private, permission=self.edit, role=self.owner)

        # Add inheritance block for single states
        sib = StateInheritanceBlock.objects.create(state=self.private, permission=self.view)
        sib = StateInheritanceBlock.objects.create(state=self.private, permission=self.edit)
        sib = StateInheritanceBlock.objects.create(state=self.public, permission=self.edit)

        workflows.utils.set_workflow(self.page_1, self.w)
github diefenbach / django-workflows / workflows / tests.py View on Github external
def test_remove_workflow_from_object(self):
        """
        """
        result = workflows.utils.get_workflow(self.user)
        self.assertEqual(result, None)

        workflows.utils.set_workflow_for_object(self.user, self.w)

        result = workflows.utils.get_workflow(self.user)
        self.assertEqual(result, self.w)

        result = workflows.utils.remove_workflow_from_object(self.user)
        self.assertEqual(result, None)
github diefenbach / django-workflows / workflows / tests.py View on Github external
def test_get_objects_for_workflow_2(self):
        """Workflow is added to content type.
        """
        result = workflows.utils.get_objects_for_workflow(self.w)
        self.assertEqual(result, [])

        ctype = ContentType.objects.get_for_model(self.user)
        workflows.utils.set_workflow(ctype, self.w)
        result = workflows.utils.get_objects_for_workflow(self.w)
        self.assertEqual(result, [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_get_objects_for_workflow_3(self):
        """Workflow is added to content type and object.
        """
        result = workflows.utils.get_objects_for_workflow(self.w)
        self.assertEqual(result, [])

        workflows.utils.set_workflow(self.user, self.w)
        result = workflows.utils.get_objects_for_workflow(self.w)
        self.assertEqual(result, [self.user])

        ctype = ContentType.objects.get_for_model(self.user)
        workflows.utils.set_workflow(ctype, self.w)
        result = workflows.utils.get_objects_for_workflow(self.w)
        self.assertEqual(result, [self.user])
github diefenbach / django-workflows / workflows / tests.py View on Github external
def test_workflow(self):
        """
        """
        workflows.utils.set_workflow(self.user, self.w)
        result = workflows.utils.get_workflow(self.user)
        self.assertEqual(result, self.w)
github unistra / django-workflow-activity / tests / tests.py View on Github external
def setUp(self):
        """
        """
        create_workflow(self)
        self.user = User.objects.create(username='test_user',
            first_name='Test', last_name='User')
        self.flat_page = FlatPage.objects.create(url='/page-1', title='Page 1',
            initializer=self.user)

        set_workflow(self.flat_page, self.w)