django-model-fsm


Namedjango-model-fsm JSON
Version 0.1.8 PyPI version JSON
download
home_pagehttps://bitbucket.org/hespul/django-model-fsm/
SummaryA package to use transitions with a Django model.
upload_time2024-05-14 20:38:26
maintainerNone
docs_urlNone
authorAlexandre Norman
requires_python<4.0,>=3.10
licenseGPL-3.0-or-later
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # django-model-fsm

A package to use transitions with a Django model.


## Usage 

``` python
from django.db import models

from django_model_fsm.dataclasses import StateData, TriggerData, WorkflowData
from django_model_fsm.models import TransitionsMixin

# States
# fmt: off
S_CREATED = StateData(
    id="created",
    label="Created",
)
S_PUBLISHED = StateData(
    id="published",
    label="Published",
)
S_ARCHIVED = StateData(
    id="archived",
    label="Archived",
)
# fmt: on

# Triggers
# fmt: off
T_PUBLISHED_CHALLENGE_MODEL = TriggerData(
    id="published_challenge_model",
    label="Publish",
    order=150,
    need_confirmation=False,
)
T_UNPUBLISHED_CHALLENGE_MODEL = TriggerData(
    id="unpublished_challenge_model",
    label="Unpublish",
    order=175,
    need_confirmation=True,
)
T_ARCHIVE_CHALLENGE_MODEL = TriggerData(
    id="archive_challenge_model",
    label="Archive",
    order=350,
    need_confirmation=True,
)
# fmt: on

challenge_model_workflow = WorkflowData(
    initial_state=S_CREATED,
    transitions_data=[
        # fmt: off
        {"trigger": T_PUBLISHED_CHALLENGE_MODEL, "source": S_CREATED, "dest": S_PUBLISHED},
        {"trigger": T_UNPUBLISHED_CHALLENGE_MODEL, "source": S_PUBLISHED, "dest": S_CREATED},
        {"trigger": T_ARCHIVE_CHALLENGE_MODEL, "source": S_PUBLISHED, "dest": S_ARCHIVED},
        # fmt: on
    ],
)


class MyModel(models.Model, TransitionsMixin):
    workflow_data = challenge_model_workflow
    workflow_callbacks = []

```

            

Raw data

            {
    "_id": null,
    "home_page": "https://bitbucket.org/hespul/django-model-fsm/",
    "name": "django-model-fsm",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "Alexandre Norman",
    "author_email": "norman@xael.org",
    "download_url": "https://files.pythonhosted.org/packages/d7/1c/3c9b3f584502ffcd4e243513bb1d967c487636e67b13e887bd81e883dcbe/django_model_fsm-0.1.8.tar.gz",
    "platform": null,
    "description": "# django-model-fsm\n\nA package to use transitions with a Django model.\n\n\n## Usage \n\n``` python\nfrom django.db import models\n\nfrom django_model_fsm.dataclasses import StateData, TriggerData, WorkflowData\nfrom django_model_fsm.models import TransitionsMixin\n\n# States\n# fmt: off\nS_CREATED = StateData(\n    id=\"created\",\n    label=\"Created\",\n)\nS_PUBLISHED = StateData(\n    id=\"published\",\n    label=\"Published\",\n)\nS_ARCHIVED = StateData(\n    id=\"archived\",\n    label=\"Archived\",\n)\n# fmt: on\n\n# Triggers\n# fmt: off\nT_PUBLISHED_CHALLENGE_MODEL = TriggerData(\n    id=\"published_challenge_model\",\n    label=\"Publish\",\n    order=150,\n    need_confirmation=False,\n)\nT_UNPUBLISHED_CHALLENGE_MODEL = TriggerData(\n    id=\"unpublished_challenge_model\",\n    label=\"Unpublish\",\n    order=175,\n    need_confirmation=True,\n)\nT_ARCHIVE_CHALLENGE_MODEL = TriggerData(\n    id=\"archive_challenge_model\",\n    label=\"Archive\",\n    order=350,\n    need_confirmation=True,\n)\n# fmt: on\n\nchallenge_model_workflow = WorkflowData(\n    initial_state=S_CREATED,\n    transitions_data=[\n        # fmt: off\n        {\"trigger\": T_PUBLISHED_CHALLENGE_MODEL, \"source\": S_CREATED, \"dest\": S_PUBLISHED},\n        {\"trigger\": T_UNPUBLISHED_CHALLENGE_MODEL, \"source\": S_PUBLISHED, \"dest\": S_CREATED},\n        {\"trigger\": T_ARCHIVE_CHALLENGE_MODEL, \"source\": S_PUBLISHED, \"dest\": S_ARCHIVED},\n        # fmt: on\n    ],\n)\n\n\nclass MyModel(models.Model, TransitionsMixin):\n    workflow_data = challenge_model_workflow\n    workflow_callbacks = []\n\n```\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "A package to use transitions with a Django model.",
    "version": "0.1.8",
    "project_urls": {
        "Homepage": "https://bitbucket.org/hespul/django-model-fsm/",
        "Repository": "https://bitbucket.org/hespul/django-model-fsm/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ddb1de0ea041e6402916a918fdfa7760ef194548da506f5999eb9a128a033358",
                "md5": "9181c3f790f38356769d29df72c59606",
                "sha256": "45fb6e7788933bb2039a0f312446e7af321172ecc47a2d88257d1d7a6f6ebd0b"
            },
            "downloads": -1,
            "filename": "django_model_fsm-0.1.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9181c3f790f38356769d29df72c59606",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 7466,
            "upload_time": "2024-05-14T20:38:24",
            "upload_time_iso_8601": "2024-05-14T20:38:24.228198Z",
            "url": "https://files.pythonhosted.org/packages/dd/b1/de0ea041e6402916a918fdfa7760ef194548da506f5999eb9a128a033358/django_model_fsm-0.1.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d71c3c9b3f584502ffcd4e243513bb1d967c487636e67b13e887bd81e883dcbe",
                "md5": "3bcac683724bac974bc302b8021b8bd5",
                "sha256": "7e3aca9ab64e1edafa67eb99c42a73f728ad16f3daf1e7ecdd4d9b6d3647e2f3"
            },
            "downloads": -1,
            "filename": "django_model_fsm-0.1.8.tar.gz",
            "has_sig": false,
            "md5_digest": "3bcac683724bac974bc302b8021b8bd5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 5685,
            "upload_time": "2024-05-14T20:38:26",
            "upload_time_iso_8601": "2024-05-14T20:38:26.242883Z",
            "url": "https://files.pythonhosted.org/packages/d7/1c/3c9b3f584502ffcd4e243513bb1d967c487636e67b13e887bd81e883dcbe/django_model_fsm-0.1.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-14 20:38:26",
    "github": false,
    "gitlab": false,
    "bitbucket": true,
    "codeberg": false,
    "bitbucket_user": "hespul",
    "bitbucket_project": "django-model-fsm",
    "lcname": "django-model-fsm"
}
        
Elapsed time: 0.25412s