edc-model-admin


Nameedc-model-admin JSON
Version 0.3.16 PyPI version JSON
download
home_pagehttps://github.com/clinicedc/edc-model-admin
SummaryEdc custom django ModelAdmin mixins, tags and templates for clinicedc/edc projects
upload_time2022-06-23 21:21:45
maintainer
docs_urlNone
authorErik van Widenfelt
requires_python>=3.9
licenseGPL license, see LICENSE
keywords django modeladmin edc clinicedc clinical trials
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            |pypi| |actions| |codecov| |downloads|

edc-model-admin
---------------

Edc custom django ModelAdmin mixins, tags and templates


ModelAdminFormAutoNumberMixin
+++++++++++++++++++++++++++++

Overrides ModelAdmin's ``get_form`` to insert question numbers and the DB field names.


ModelAdminNextUrlRedirectMixin
++++++++++++++++++++++++++++++

Skips the ``changelist`` and redirects to the next CRF or Requisition listed in an edc visit schedule if "[Save and Next]"
is clicked instead of "[SAVE]"

.. code-block:: python

	class BaseModelAdmin:

	    search_fields = ("subject_identifier",)

	    add_form_template = "edc_model_admin/admin/change_form.html"
	    change_form_template = "edc_model_admin/admin/change_form.html"
	    change_list_template = "edc_model_admin/admin/change_list.html"


	@admin.register(CrfTwo)
	class CrfTwoAdmin(BaseModelAdmin, ModelAdminNextUrlRedirectMixin, admin.ModelAdmin):
	    show_save_next = True
	    show_cancel = True

You need to use the included ``change_form.html`` to override the submit buttons on the ``admin`` form.

See also:: ``edc_visit_schedule``


ModelAdminRedirectOnDeleteMixin
+++++++++++++++++++++++++++++++

Redirects the admin form on save to a view other than the default ``changelist`` if ``post_url_on_delete_name`` is set.

.. code-block:: python

	@admin.register(CrfFive)
	class CrfFiveAdmin(ModelAdminRedirectOnDeleteMixin, admin.ModelAdmin):

	    post_url_on_delete_name = "dashboard2_app:dashboard_url"

	    def post_url_on_delete_kwargs(self, request, obj):
	        return {'subject_identifier': obj.subject_identifier}

You can also store url names in the request object if used together with the Middleware from ``edc_dashboard`` and ``edc_subject_dashboard``.
This is useful if you do not know the namespace until deployment.

For example, add to settings:

.. code-block:: python

    MIDDLEWARE=[
    	...,
        'edc_dashboard.middleware.DashboardMiddleware',
        'edc_subject_dashboard.middleware.DashboardMiddleware',
    ],

    DASHBOARD_URL_NAMES={
        'subject_dashboard_url': 'dashboard_app:subject_dashboard_url',
    },

and then declare the model admin class:

.. code-block:: python

	@admin.register(CrfFive)
	class CrfFiveAdmin(ModelAdminRedirectOnDeleteMixin, admin.ModelAdmin):

	    post_url_on_delete_name = "subject_dashboard_url"

	    def post_url_on_delete_kwargs(self, request, obj):
	        return {'subject_identifier': obj.subject_identifier}

``ModelAdminRedirectOnDeleteMixin`` will attempt to get the urlname from the request object using ``post_url_on_delete_name`` as a dictionary key.



.. |pypi| image:: https://img.shields.io/pypi/v/edc-model-admin.svg
    :target: https://pypi.python.org/pypi/edc-model-admin

.. |actions| image:: https://github.com/clinicedc/edc-model-admin/workflows/build/badge.svg?branch=develop
  :target: https://github.com/clinicedc/edc-model-admin/actions?query=workflow:build

.. |codecov| image:: https://codecov.io/gh/clinicedc/edc-model-admin/branch/develop/graph/badge.svg
  :target: https://codecov.io/gh/clinicedc/edc-model-admin

.. |downloads| image:: https://pepy.tech/badge/edc-model-admin
   :target: https://pepy.tech/project/edc-model-admin

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/clinicedc/edc-model-admin",
    "name": "edc-model-admin",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "django modeladmin edc clinicedc clinical trials",
    "author": "Erik van Widenfelt",
    "author_email": "ew2789@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b2/ee/9a529a8871383052161abad8f5305e13dc5f304ce43f1e9c04966b7ffd04/edc-model-admin-0.3.16.tar.gz",
    "platform": null,
    "description": "|pypi| |actions| |codecov| |downloads|\n\nedc-model-admin\n---------------\n\nEdc custom django ModelAdmin mixins, tags and templates\n\n\nModelAdminFormAutoNumberMixin\n+++++++++++++++++++++++++++++\n\nOverrides ModelAdmin's ``get_form`` to insert question numbers and the DB field names.\n\n\nModelAdminNextUrlRedirectMixin\n++++++++++++++++++++++++++++++\n\nSkips the ``changelist`` and redirects to the next CRF or Requisition listed in an edc visit schedule if \"[Save and Next]\"\nis clicked instead of \"[SAVE]\"\n\n.. code-block:: python\n\n\tclass BaseModelAdmin:\n\n\t    search_fields = (\"subject_identifier\",)\n\n\t    add_form_template = \"edc_model_admin/admin/change_form.html\"\n\t    change_form_template = \"edc_model_admin/admin/change_form.html\"\n\t    change_list_template = \"edc_model_admin/admin/change_list.html\"\n\n\n\t@admin.register(CrfTwo)\n\tclass CrfTwoAdmin(BaseModelAdmin, ModelAdminNextUrlRedirectMixin, admin.ModelAdmin):\n\t    show_save_next = True\n\t    show_cancel = True\n\nYou need to use the included ``change_form.html`` to override the submit buttons on the ``admin`` form.\n\nSee also:: ``edc_visit_schedule``\n\n\nModelAdminRedirectOnDeleteMixin\n+++++++++++++++++++++++++++++++\n\nRedirects the admin form on save to a view other than the default ``changelist`` if ``post_url_on_delete_name`` is set.\n\n.. code-block:: python\n\n\t@admin.register(CrfFive)\n\tclass CrfFiveAdmin(ModelAdminRedirectOnDeleteMixin, admin.ModelAdmin):\n\n\t    post_url_on_delete_name = \"dashboard2_app:dashboard_url\"\n\n\t    def post_url_on_delete_kwargs(self, request, obj):\n\t        return {'subject_identifier': obj.subject_identifier}\n\nYou can also store url names in the request object if used together with the Middleware from ``edc_dashboard`` and ``edc_subject_dashboard``.\nThis is useful if you do not know the namespace until deployment.\n\nFor example, add to settings:\n\n.. code-block:: python\n\n    MIDDLEWARE=[\n    \t...,\n        'edc_dashboard.middleware.DashboardMiddleware',\n        'edc_subject_dashboard.middleware.DashboardMiddleware',\n    ],\n\n    DASHBOARD_URL_NAMES={\n        'subject_dashboard_url': 'dashboard_app:subject_dashboard_url',\n    },\n\nand then declare the model admin class:\n\n.. code-block:: python\n\n\t@admin.register(CrfFive)\n\tclass CrfFiveAdmin(ModelAdminRedirectOnDeleteMixin, admin.ModelAdmin):\n\n\t    post_url_on_delete_name = \"subject_dashboard_url\"\n\n\t    def post_url_on_delete_kwargs(self, request, obj):\n\t        return {'subject_identifier': obj.subject_identifier}\n\n``ModelAdminRedirectOnDeleteMixin`` will attempt to get the urlname from the request object using ``post_url_on_delete_name`` as a dictionary key.\n\n\n\n.. |pypi| image:: https://img.shields.io/pypi/v/edc-model-admin.svg\n    :target: https://pypi.python.org/pypi/edc-model-admin\n\n.. |actions| image:: https://github.com/clinicedc/edc-model-admin/workflows/build/badge.svg?branch=develop\n  :target: https://github.com/clinicedc/edc-model-admin/actions?query=workflow:build\n\n.. |codecov| image:: https://codecov.io/gh/clinicedc/edc-model-admin/branch/develop/graph/badge.svg\n  :target: https://codecov.io/gh/clinicedc/edc-model-admin\n\n.. |downloads| image:: https://pepy.tech/badge/edc-model-admin\n   :target: https://pepy.tech/project/edc-model-admin\n",
    "bugtrack_url": null,
    "license": "GPL license, see LICENSE",
    "summary": "Edc custom django ModelAdmin mixins, tags and templates for clinicedc/edc projects",
    "version": "0.3.16",
    "split_keywords": [
        "django",
        "modeladmin",
        "edc",
        "clinicedc",
        "clinical",
        "trials"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "cabf388113d79ea6cac2dbd17eef1bc7",
                "sha256": "43b173fbf4352fb0bcbad8ba6c0868b579a995ae3d74dee5a4369f5bff26df16"
            },
            "downloads": -1,
            "filename": "edc_model_admin-0.3.16-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cabf388113d79ea6cac2dbd17eef1bc7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 64029,
            "upload_time": "2022-06-23T21:21:43",
            "upload_time_iso_8601": "2022-06-23T21:21:43.907413Z",
            "url": "https://files.pythonhosted.org/packages/29/fd/c74d529b03b342b19f2e7d734fa4630f79859e1aca2008d4c4e75cad46b9/edc_model_admin-0.3.16-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "b2f5e2576b40ff4f0133327bd38c6ec3",
                "sha256": "8b5c12215acf5c0a415470ebf22073289ac578b9a234d269948d862944db1bf7"
            },
            "downloads": -1,
            "filename": "edc-model-admin-0.3.16.tar.gz",
            "has_sig": false,
            "md5_digest": "b2f5e2576b40ff4f0133327bd38c6ec3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 50011,
            "upload_time": "2022-06-23T21:21:45",
            "upload_time_iso_8601": "2022-06-23T21:21:45.908979Z",
            "url": "https://files.pythonhosted.org/packages/b2/ee/9a529a8871383052161abad8f5305e13dc5f304ce43f1e9c04966b7ffd04/edc-model-admin-0.3.16.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-06-23 21:21:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "clinicedc",
    "github_project": "edc-model-admin",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "lcname": "edc-model-admin"
}
        
Elapsed time: 0.54667s