How to use the river.models.State.objects.get function in river

To help you get started, weโ€™ve selected a few river 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 javrasya / django-river / features / steps / issue_tracking_steps.py View on Github external
def _approve(context, workflow_object_identifier, username, next_state):
    from django.contrib.auth.models import User
    from river.models import State

    workflow_object = getattr(context, "workflow_objects", {})[workflow_object_identifier]

    user = User.objects.get(username=username)
    workflow_object.river.my_field.approve(as_user=user, next_state=State.objects.get(label=next_state))
github javrasya / django-river / features / steps / basic_steps.py View on Github external
def workflow(context, identifier, initial_state_label):
    from django.contrib.contenttypes.models import ContentType
    from river.tests.models import BasicTestModel
    from river.models import State
    from river.models.factories import WorkflowFactory

    content_type = ContentType.objects.get_for_model(BasicTestModel)
    initial_state = State.objects.get(label=initial_state_label)
    workflow = WorkflowFactory(initial_state=initial_state, content_type=content_type, field_name="my_field")
    workflows = getattr(context, "workflows", {})
    workflows[identifier] = workflow
    context.workflows = workflows
github javrasya / django-river / features / steps / basic_steps.py View on Github external
def transition(context, source_state_label, destination_state_label, workflow_identifier):
    from river.models import State
    from river.models.factories import TransitionMetaFactory

    workflow = getattr(context, "workflows", {})[workflow_identifier]
    source_state = State.objects.get(label=source_state_label)
    destination_state = State.objects.get(label=destination_state_label)
    transition = TransitionMetaFactory.create(
        workflow=workflow,
        source_state=source_state,
        destination_state=destination_state,
    )
    identifier = source_state_label + destination_state_label
    transitions = getattr(context, "transitions", {})
    transitions[identifier] = transition
    context.transitions = transitions
github javrasya / django-river / features / steps / basic_steps.py View on Github external
def jump_workflow_object(context, workflow_object_identifier, state_label):
    from river.models import State

    state = State.objects.get(label=state_label)
    workflow_object = getattr(context, "workflow_objects", {})[workflow_object_identifier]
    workflow_object.river.my_field.jump_to(state)
github javrasya / django-river / features / steps / basic_steps.py View on Github external
def transition(context, source_state_label, destination_state_label, workflow_identifier):
    from river.models import State
    from river.models.factories import TransitionMetaFactory

    workflow = getattr(context, "workflows", {})[workflow_identifier]
    source_state = State.objects.get(label=source_state_label)
    destination_state = State.objects.get(label=destination_state_label)
    transition = TransitionMetaFactory.create(
        workflow=workflow,
        source_state=source_state,
        destination_state=destination_state,
    )
    identifier = source_state_label + destination_state_label
    transitions = getattr(context, "transitions", {})
    transitions[identifier] = transition
    context.transitions = transitions