|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/f3/55/ca4a06dc3f919e0d49177da9d3fec81910e386ac88068f77d7f4075fd07e/edc-model-admin-0.3.73.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.73",
"project_urls": {
"Homepage": "https://github.com/clinicedc/edc-model-admin"
},
"split_keywords": [
"django",
"modeladmin",
"edc",
"clinicedc",
"clinical",
"trials"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "79d48065c1d7fe488ed9a1be511458dc8e67099147185e60006237d6b0aee158",
"md5": "6dd58e83c3fde4e25077dc45b7300cd8",
"sha256": "32ebae57783ff9859fc90fedcd002550162595a08568675a9b7c231fa673b25e"
},
"downloads": -1,
"filename": "edc_model_admin-0.3.73-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6dd58e83c3fde4e25077dc45b7300cd8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 93047,
"upload_time": "2024-03-27T03:51:38",
"upload_time_iso_8601": "2024-03-27T03:51:38.886951Z",
"url": "https://files.pythonhosted.org/packages/79/d4/8065c1d7fe488ed9a1be511458dc8e67099147185e60006237d6b0aee158/edc_model_admin-0.3.73-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f355ca4a06dc3f919e0d49177da9d3fec81910e386ac88068f77d7f4075fd07e",
"md5": "ac43dd3f8cd277e1155962f4efb5134c",
"sha256": "88c5a4d4e7e7a75d322c3d05a540aa9abc27f90a1550010097e62ddf3ca68f9e"
},
"downloads": -1,
"filename": "edc-model-admin-0.3.73.tar.gz",
"has_sig": false,
"md5_digest": "ac43dd3f8cd277e1155962f4efb5134c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 66772,
"upload_time": "2024-03-27T03:51:41",
"upload_time_iso_8601": "2024-03-27T03:51:41.589468Z",
"url": "https://files.pythonhosted.org/packages/f3/55/ca4a06dc3f919e0d49177da9d3fec81910e386ac88068f77d7f4075fd07e/edc-model-admin-0.3.73.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-27 03:51:41",
"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"
}