{
"info": {
"author": "Pivotal Energy Solutions",
"author_email": "sklass@pivotalenergysolutions.com",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7"
],
"description": "# Django States\n\n## Description\n\nState engine for django models. Define a state graph for a model and\nremember the state of each object. State transitions can be logged for\nobjects.\n\n### Note\n_This fork provides for changes specifically for Pivotal Energy Solutions_\n\n## Installation\n\n```sh\npip install pivotal-django-states\n```\n\n\n## Usage example\n\n```python\n from django_states.fields import StateField\n from django_states.machine import StateMachine, StateDefinition, StateTransition\n\n class PurchaseStateMachine(StateMachine):\n log_transitions = True\n\n # possible states\n class initiated(StateDefinition):\n description = _('Purchase initiated')\n initial = True\n\n class paid(StateDefinition):\n description = _('Purchase paid')\n\n def handler(self, instance):\n code_to_execute_when_arriving_in_this_state()\n\n class shipped(StateDefinition):\n description = _('Purchase shipped')\n\n # state transitions\n class mark_paid(StateTransition):\n from_state = 'initiated'\n to_state = 'paid'\n description = 'Mark this purchase as paid'\n\n class ship(StateTransition):\n from_state = 'paid'\n to_state = 'shipped'\n description = 'Ship purchase'\n\n def handler(transition, instance, user):\n code_to_execute_during_this_transition()\n\n def has_permission(transition, instance, user):\n return true_when_user_can_make_this_transition()\n\n class Purchase(StateModel):\n purchase_state = StateField(machine=PurchaseStateMachine, default='initiated')\n ... (other fields for a purchase)\n```\n\nIf ``log_transitions`` is enabled, another model is created. Everything\nshould be compatible with South\\_ for migrations.\n\nNote: If you're creating a ``DataMigration`` in\n`South `__, remember to use\n``obj.save(no_state_validation=True)``\n\nUsage example:\n\n```python\n\n p = Purchase()\n\n # Will automatically create state object for this purchase, in the\n # initial state.\n p.save()\n p.get_purchase_state_info().make_transition('mark_paid', request.user) # User parameter is optional\n p.state # Will return 'paid'\n p.get_purchase_state_info().description # Will return 'Purchase paid'\n\n # Returns an iterator of possible transitions for this purchase.\n p.get_purchase_state_info().possible_transitions()\n\n # Which can be used like this..\n [x.get_name() for x in p.possible_transitions]\n```\n\nFor better transition control, override:\n\n- ``has_permission(self, instance, user)``: Check whether this user is\n allowed to make this transition.\n- ``handler(self, instance, user)``: Code to run during this\n transition. When an exception has been raised in here, the transition\n will not be made.\n\nGet all objects in a certain state::\n\n Purchase.objects.filter(state='initiated')\n\n## Validation\n\nYou can add a test that needs to pass before a state transition can be\nexecuted. Well, you can add 2: one based on the current user\n(``has_permission``) and one generic (``validate``).\n\nSo on a ``StateTransition``-object you need to specify an extra\n``validate`` function (signature is ``validate(cls, instance)``). This\nshould yield ``TransitionValidationError``, this way you can return\nmultiple errors on that need to pass before the transition can happen.\n\nThe ``has_permission`` function (signature\n``has_permission(transition, instance, user)``) should check whether the\ngiven user is allowed to make the transition. E.g. a super user can\nmoderate all comments while other users can only moderate comments on\ntheir blog-posts.\n\n## Groups\n\nSometimes you want to group several states together, since for a certain\nview (or other content) it doesn't really matter which of the states it\nis. We support 2 different state groups, inclusive (only these) or\nexclusive (everything but these):\n\n```python\n\n class is_paid(StateGroup):\n states = ['paid', 'shipped']\n\n class is_paid(StateGroup):\n exclude_states = ['initiated']\n```\n\n## State graph\n\nYou can get a graph of your states by running the ``graph_states``\nmanagement command.\n\n```sh\n\n python manage.py graph_states myapp.Purchase.state\n```\n\nThis requires [graphviz]() and python bindings for\ngraphviz: ``pygraphviz`` and ``yapgvb``.\n\n\n\n\n",
"description_content_type": "text/markdown",
"docs_url": null,
"download_url": "https://github.com/pivotal-energy-solutions/django-states2/archive/1.6.14.tar.gz",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/pivotal-energy-solutions/django-states2",
"keywords": "django state-machine",
"license": "",
"maintainer": "",
"maintainer_email": "",
"name": "pivotal-django-states",
"package_url": "https://pypi.org/project/pivotal-django-states/",
"platform": "",
"project_url": "https://pypi.org/project/pivotal-django-states/",
"project_urls": {
"Bug Reports": "https://github.com/pivotal-energy-solutions/django-states2/issues",
"Download": "https://github.com/pivotal-energy-solutions/django-states2/archive/1.6.14.tar.gz",
"Homepage": "https://github.com/pivotal-energy-solutions/django-states2",
"Original Source": "https://github.com/vikingco/django-states2",
"Say Thanks!": "https://saythanks.io/to/rh0dium"
},
"release_url": "https://pypi.org/project/pivotal-django-states/1.6.14/",
"requires_dist": [
"django (<2.0,>=1.11)"
],
"requires_python": "",
"summary": "State machine for django models",
"version": "1.6.14"
},
"last_serial": 4334662,
"releases": {
"1.0.0": [
{
"comment_text": "",
"digests": {
"md5": "847b6cadd20174c7ebb5ad3dac41a8e4",
"sha256": "15046b85c788337c1df71e55e5460ef9f69ace33b57b3e3eec227728ca23dd2a"
},
"downloads": -1,
"filename": "pivotal_django_states-1.0.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "847b6cadd20174c7ebb5ad3dac41a8e4",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 25656,
"upload_time": "2018-04-26T01:36:09",
"url": "https://files.pythonhosted.org/packages/be/de/fb3ee38fc5134610ee02f86f7a4f2d834ba3ffdb171a809e08de5c62b005/pivotal_django_states-1.0.0-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "049a27d55156f5cc6d6d765c1897f594",
"sha256": "92ea6fb820e79342901a82f373892225b70e28b984958b2e77926d5e628df1e5"
},
"downloads": -1,
"filename": "pivotal_django_states-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "049a27d55156f5cc6d6d765c1897f594",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 23795,
"upload_time": "2018-04-26T01:36:10",
"url": "https://files.pythonhosted.org/packages/2b/d3/c0324e438551cb4d328ef980b61cfe1967ec18d89d4c6a92f6d386b465ee/pivotal_django_states-1.0.0.tar.gz"
}
],
"1.0.0rc2": [
{
"comment_text": "",
"digests": {
"md5": "02c0c5803486941b8caf941886e0fd79",
"sha256": "61a8d1dddc62499875fe9b332fe9001965a367ce385fca46ef5c0ea34c2d6b04"
},
"downloads": -1,
"filename": "pivotal_django_states-1.0.0rc2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "02c0c5803486941b8caf941886e0fd79",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 25695,
"upload_time": "2018-04-26T01:31:27",
"url": "https://files.pythonhosted.org/packages/d2/60/5a89daa9807dd99b68814b59b765b1c6968d050f08f103f00c52388feedb/pivotal_django_states-1.0.0rc2-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "d1becd8a7eb88f3ec2276ad0e661ed41",
"sha256": "80d1fc036b89f646a2226abb420eaec208a0544dd5356936bc27a92f9ea14aa3"
},
"downloads": -1,
"filename": "pivotal_django_states-1.0.0rc2.tar.gz",
"has_sig": false,
"md5_digest": "d1becd8a7eb88f3ec2276ad0e661ed41",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 23801,
"upload_time": "2018-04-26T01:31:28",
"url": "https://files.pythonhosted.org/packages/b8/44/c1c97d669d2089b0a1b7588a53b1acdbd62c47f607ee8f59b086c35c0621/pivotal_django_states-1.0.0rc2.tar.gz"
}
],
"1.6.14": [
{
"comment_text": "",
"digests": {
"md5": "a3777cb3ac284b3b9888fbb0c1252482",
"sha256": "e026a22450361b039e17868c84577e520b89cbd609eea226275f23bcb8e30a08"
},
"downloads": -1,
"filename": "pivotal_django_states-1.6.14-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "a3777cb3ac284b3b9888fbb0c1252482",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 25691,
"upload_time": "2018-10-03T00:11:11",
"url": "https://files.pythonhosted.org/packages/12/78/897dc7f64b44fd49043dd343f5d742e4758d151ae05b4dcaba5d2d95de00/pivotal_django_states-1.6.14-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "8ea8cd954ea88ef0e37f6378cf8889e2",
"sha256": "89d254daf4055f5533251210d5ee1059cbfc26551b9db1d2ba90d56335338e93"
},
"downloads": -1,
"filename": "pivotal_django_states-1.6.14.tar.gz",
"has_sig": false,
"md5_digest": "8ea8cd954ea88ef0e37f6378cf8889e2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 23879,
"upload_time": "2018-10-03T00:11:13",
"url": "https://files.pythonhosted.org/packages/6f/75/82c0194d8c42b1db85a13fb72abeaa6aa7f03ea7dc6bef71dcee01fa5e8d/pivotal_django_states-1.6.14.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "a3777cb3ac284b3b9888fbb0c1252482",
"sha256": "e026a22450361b039e17868c84577e520b89cbd609eea226275f23bcb8e30a08"
},
"downloads": -1,
"filename": "pivotal_django_states-1.6.14-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "a3777cb3ac284b3b9888fbb0c1252482",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 25691,
"upload_time": "2018-10-03T00:11:11",
"url": "https://files.pythonhosted.org/packages/12/78/897dc7f64b44fd49043dd343f5d742e4758d151ae05b4dcaba5d2d95de00/pivotal_django_states-1.6.14-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "8ea8cd954ea88ef0e37f6378cf8889e2",
"sha256": "89d254daf4055f5533251210d5ee1059cbfc26551b9db1d2ba90d56335338e93"
},
"downloads": -1,
"filename": "pivotal_django_states-1.6.14.tar.gz",
"has_sig": false,
"md5_digest": "8ea8cd954ea88ef0e37f6378cf8889e2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 23879,
"upload_time": "2018-10-03T00:11:13",
"url": "https://files.pythonhosted.org/packages/6f/75/82c0194d8c42b1db85a13fb72abeaa6aa7f03ea7dc6bef71dcee01fa5e8d/pivotal_django_states-1.6.14.tar.gz"
}
]
}