django-fsm-admin-django-4


Namedjango-fsm-admin-django-4 JSON
Version 1.2.7 PyPI version JSON
download
home_pagehttps://github.com/7tg/django-fsm-admin-django-4
SummaryIntegrate django-fsm state transitions into the django admin with django 4 support.
upload_time2024-01-03 12:46:39
maintainer
docs_urlNone
authorG Adventures
requires_python
licenseMIT
keywords django fsm admin
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            django-fsm-admin-django-4
=========================

Mixin and template tags to integrate django-fsm_ state transitions into the
Django Admin.

Note: This is a fork of https://github.com/gadventures/django-fsm-admin
which is not maintained anymore. This fork is compatible with Django 4.

Installation
------------

.. code:: sh

   $ pip install django-fsm-admin-django-4

Or from GitHub:

.. code:: sh

   $ pip install -e git://github.com/7tg/django-fsm-admin-django-4.git#egg=django-fsm-admin-django-4

Usage
-----

1. Add ``fsm_admin`` to your ``INSTALLED_APPS``.

2. Ensure that you have ``"django.core.context_processors.request"`` in your
   ``TEMPLATE_CONTEXT_PROCESSORS`` in Django settings. If the setting variable
   is not yet defined, add:

.. code:: python

   from django.conf import settings

   TEMPLATE_CONTEXT_PROCESSORS = settings.TEMPLATE_CONTEXT_PROCESSORS + (
       "django.core.context_processors.request",
   )

3. In your ``admin.py`` file, use ``FSMTransitionMixin`` to add behaviour to your
   ModelAdmin. ``FSMTransitionMixin`` should be before ``ModelAdmin``, the order is
   important.

It assumes that your workflow state field is named ``state``, however you can
override it or add additional workflow state fields with the attribute
``fsm_field``.

.. code:: python

   from fsm_admin.mixins import FSMTransitionMixin

   class YourModelAdmin(FSMTransitionMixin, admin.ModelAdmin):
       # The name of one or more FSMFields on the model to transition
       fsm_field = ['wf_state',]

   admin.site.register(YourModel, YourModelAdmin)

4. By adding ``custom=dict(admin=False)`` to the transition decorator, one can
   disallow a transition to show up in the admin interface. This specially is
   useful, if the transition method accepts parameters without default values,
   since in **django-fsm-admin-django-4** no arguments can be passed into the transition
   method.

.. code:: python

    @transition(
       field='state',
       source=['startstate'],
       target='finalstate',
       custom=dict(admin=False),
    )
    def do_something(self, param):
       # will not add a button "Do Something" to your admin model interface

By adding ``FSM_ADMIN_FORCE_PERMIT = True`` to your configuration settings, the
above restriction becomes the default. Then one must explicitly allow that a
transition method shows up in the admin interface.

.. code:: python

   @transition(
       field='state',
       source=['startstate'],
       target='finalstate',
       custom=dict(admin=True),
   )
   def proceed(self):
       # will add a button "Proceed" to your admin model interface

This is useful, if most of your state transitions are handled by other means,
such as external events communicating with the API of your application.

Try the example
---------------

.. code:: sh

   $ git clone git@github.com:7tg/django-fsm-admin-django-4.git
   $ cd django-fsm-admin-django-4
   $ mkvirtualenv fsm_admin
   $ pip install -r requirements.txt
   $ python setup.py develop
   $ cd example
   $ python manage.py syncdb
   $ python manage.py runserver


.. _django-fsm: https://github.com/kmmbvnr/django-fsm



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/7tg/django-fsm-admin-django-4",
    "name": "django-fsm-admin-django-4",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "django fsm admin",
    "author": "G Adventures",
    "author_email": "software@gadventures.com",
    "download_url": "https://files.pythonhosted.org/packages/8c/de/806617180fc7f8fff9172686618cf11c4cd7a3feffa9ca302020596f7055/django-fsm-admin-django-4-1.2.7.tar.gz",
    "platform": "any",
    "description": "django-fsm-admin-django-4\n=========================\n\nMixin and template tags to integrate django-fsm_ state transitions into the\nDjango Admin.\n\nNote: This is a fork of https://github.com/gadventures/django-fsm-admin\nwhich is not maintained anymore. This fork is compatible with Django 4.\n\nInstallation\n------------\n\n.. code:: sh\n\n   $ pip install django-fsm-admin-django-4\n\nOr from GitHub:\n\n.. code:: sh\n\n   $ pip install -e git://github.com/7tg/django-fsm-admin-django-4.git#egg=django-fsm-admin-django-4\n\nUsage\n-----\n\n1. Add ``fsm_admin`` to your ``INSTALLED_APPS``.\n\n2. Ensure that you have ``\"django.core.context_processors.request\"`` in your\n   ``TEMPLATE_CONTEXT_PROCESSORS`` in Django settings. If the setting variable\n   is not yet defined, add:\n\n.. code:: python\n\n   from django.conf import settings\n\n   TEMPLATE_CONTEXT_PROCESSORS = settings.TEMPLATE_CONTEXT_PROCESSORS + (\n       \"django.core.context_processors.request\",\n   )\n\n3. In your ``admin.py`` file, use ``FSMTransitionMixin`` to add behaviour to your\n   ModelAdmin. ``FSMTransitionMixin`` should be before ``ModelAdmin``, the order is\n   important.\n\nIt assumes that your workflow state field is named ``state``, however you can\noverride it or add additional workflow state fields with the attribute\n``fsm_field``.\n\n.. code:: python\n\n   from fsm_admin.mixins import FSMTransitionMixin\n\n   class YourModelAdmin(FSMTransitionMixin, admin.ModelAdmin):\n       # The name of one or more FSMFields on the model to transition\n       fsm_field = ['wf_state',]\n\n   admin.site.register(YourModel, YourModelAdmin)\n\n4. By adding ``custom=dict(admin=False)`` to the transition decorator, one can\n   disallow a transition to show up in the admin interface. This specially is\n   useful, if the transition method accepts parameters without default values,\n   since in **django-fsm-admin-django-4** no arguments can be passed into the transition\n   method.\n\n.. code:: python\n\n    @transition(\n       field='state',\n       source=['startstate'],\n       target='finalstate',\n       custom=dict(admin=False),\n    )\n    def do_something(self, param):\n       # will not add a button \"Do Something\" to your admin model interface\n\nBy adding ``FSM_ADMIN_FORCE_PERMIT = True`` to your configuration settings, the\nabove restriction becomes the default. Then one must explicitly allow that a\ntransition method shows up in the admin interface.\n\n.. code:: python\n\n   @transition(\n       field='state',\n       source=['startstate'],\n       target='finalstate',\n       custom=dict(admin=True),\n   )\n   def proceed(self):\n       # will add a button \"Proceed\" to your admin model interface\n\nThis is useful, if most of your state transitions are handled by other means,\nsuch as external events communicating with the API of your application.\n\nTry the example\n---------------\n\n.. code:: sh\n\n   $ git clone git@github.com:7tg/django-fsm-admin-django-4.git\n   $ cd django-fsm-admin-django-4\n   $ mkvirtualenv fsm_admin\n   $ pip install -r requirements.txt\n   $ python setup.py develop\n   $ cd example\n   $ python manage.py syncdb\n   $ python manage.py runserver\n\n\n.. _django-fsm: https://github.com/kmmbvnr/django-fsm\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Integrate django-fsm state transitions into the django admin with django 4 support.",
    "version": "1.2.7",
    "project_urls": {
        "Homepage": "https://github.com/7tg/django-fsm-admin-django-4"
    },
    "split_keywords": [
        "django",
        "fsm",
        "admin"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8cde806617180fc7f8fff9172686618cf11c4cd7a3feffa9ca302020596f7055",
                "md5": "4f635189a4eae8bd5f977f56eaa51a25",
                "sha256": "729d455444f1116d25affdf8d3956aad7ece4e532893db71ab46c82524558b9e"
            },
            "downloads": -1,
            "filename": "django-fsm-admin-django-4-1.2.7.tar.gz",
            "has_sig": false,
            "md5_digest": "4f635189a4eae8bd5f977f56eaa51a25",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 11799,
            "upload_time": "2024-01-03T12:46:39",
            "upload_time_iso_8601": "2024-01-03T12:46:39.649119Z",
            "url": "https://files.pythonhosted.org/packages/8c/de/806617180fc7f8fff9172686618cf11c4cd7a3feffa9ca302020596f7055/django-fsm-admin-django-4-1.2.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-03 12:46:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "7tg",
    "github_project": "django-fsm-admin-django-4",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "django-fsm-admin-django-4"
}
        
Elapsed time: 0.16848s