|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/actions/workflows/build.yml/badge.svg
:target: https://github.com/clinicedc/edc-model-admin/actions/workflows/build.yml
.. |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": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "django modeladmin edc clinicedc clinical trials",
"author": "Erik van Widenfelt",
"author_email": "ew2789@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/2a/f1/3aac78e2502e8d52bbfde57d4309bcf3ff4d88ce7645665aeb6cdba39abb/edc_model_admin-0.3.78.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/actions/workflows/build.yml/badge.svg\n :target: https://github.com/clinicedc/edc-model-admin/actions/workflows/build.yml\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.78",
"project_urls": {
"Homepage": "https://github.com/clinicedc/edc-model-admin"
},
"split_keywords": [
"django",
"modeladmin",
"edc",
"clinicedc",
"clinical",
"trials"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ec104888dcec860ef67fef165c1ec6575ae9a3bd64d40ae00b4bb15ba8664b05",
"md5": "de1fc8326c0e49fbec7409104aa34151",
"sha256": "77b4b580fbd016d4b8a82b3063bed3da119a7f8091fb341c4d6a1958b0c6be73"
},
"downloads": -1,
"filename": "edc_model_admin-0.3.78-py3-none-any.whl",
"has_sig": false,
"md5_digest": "de1fc8326c0e49fbec7409104aa34151",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 93377,
"upload_time": "2024-08-23T16:53:35",
"upload_time_iso_8601": "2024-08-23T16:53:35.589086Z",
"url": "https://files.pythonhosted.org/packages/ec/10/4888dcec860ef67fef165c1ec6575ae9a3bd64d40ae00b4bb15ba8664b05/edc_model_admin-0.3.78-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2af13aac78e2502e8d52bbfde57d4309bcf3ff4d88ce7645665aeb6cdba39abb",
"md5": "5ce9c55c0a7badbb192383e15b853be6",
"sha256": "06d7a1f4f0f29f88eee302ca083d018e489d0ba422642dd62f4a9c75e80b3a67"
},
"downloads": -1,
"filename": "edc_model_admin-0.3.78.tar.gz",
"has_sig": false,
"md5_digest": "5ce9c55c0a7badbb192383e15b853be6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 67073,
"upload_time": "2024-08-23T16:53:37",
"upload_time_iso_8601": "2024-08-23T16:53:37.283851Z",
"url": "https://files.pythonhosted.org/packages/2a/f1/3aac78e2502e8d52bbfde57d4309bcf3ff4d88ce7645665aeb6cdba39abb/edc_model_admin-0.3.78.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-23 16:53:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "clinicedc",
"github_project": "edc-model-admin",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "edc-model-admin"
}