Skip to content

rbarrois/django_xworkflows

Folders and files

NameName
Last commit message
Last commit date
May 1, 2021
May 1, 2021
Mar 9, 2020
May 1, 2021
May 1, 2021
Feb 24, 2017
Jun 26, 2016
Mar 9, 2020
May 1, 2021
May 1, 2021
Jun 15, 2016
Nov 30, 2012
May 1, 2021
May 1, 2021
May 1, 2021

Repository files navigation

Django-XWorkflows

https://secure.travis-ci.org/rbarrois/django_xworkflows.png?branch=master Latest Version Supported Python versions Wheel status License

Use XWorkflows along with Django models.

Django-XWorkflows allow to bind a Django model to a workflow, with a few extra features:

  • Auto-save after transitions
  • Log each action into the database

Define a workflow and add it to a model:

from django import models
from django_xworkflows import models as xwf_models

class MyWorkflow(xwf_models.Workflow):
    states = (
        ('new', _(u"New")),
        ('old', _(u"Old")),
    )
    transitions = (
        ('get_old', 'new', 'old'),
    )
    initial_state = 'new'

class MyModel(xwf_models.WorkflowEnabled, models.Model):

    state = xwf_models.StateField(MyWorkflow)

Use the workflow:

>>> obj = MyModel()
>>> obj.state  # Defaults to the initial_state
State('new')
>>> # Perform a transition
>>> obj.get_old()
>>> obj.state
State('old')
>>> # Object was saved to the database
>>> obj.pk
1
>>> # Logs were saved to the database
>>> xwf_models.TransitionLog.objects.all()
[TransitionLog(MyModel: new -> old at 2012-04-14T12:10:00+0200)]

Links

About

Library to plug xworkflows into django models.

Resources

License

Stars

Watchers

Forks

Packages

No packages published