How to use the river.models.state.State 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 / river / services / state.py View on Github external
def get_final_states(content_type):

        """
        A state which is not a source of a transition but can be destination of a transition OR not (a source of a transition and this transition direction is FORWARD)
        """
        proceedings = ProceedingService.get_final_proceedings(content_type)
        if proceedings.count() == 0:
            raise RiverException(ErrorCode.NO_AVAILABLE_FINAL_STATE, 'There is no available final state for the content type %s.' % content_type)

        return State.objects.filter(pk__in=proceedings.values_list('meta__transition__destination_state', flat=True))
github javrasya / django-river / river / models / state.py View on Github external
def details(self):
        detail = super(State, self).details()
        detail.update(
            {
                'label': self.label,
                'description': self.description
            }
        )
        return detail
github javrasya / django-river / river / models / fields / state.py View on Github external
def __init__(self, *args, **kwargs):
        self.field_name = None
        kwargs['null'] = True
        kwargs['blank'] = True
        kwargs['to'] = '%s.%s' % (State._meta.app_label, State._meta.object_name)
        kwargs['on_delete'] = kwargs.get('on_delete', CASCADE)
        kwargs['related_name'] = "+"
        super(StateField, self).__init__(*args, **kwargs)