|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.12",
"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/0d/d5/b375db2328f6ea68b8c63061e4702bbd4a09519b76c8a98cee6d3b416d43/edc_model_admin-0.3.80.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.80",
"project_urls": {
"Homepage": "https://github.com/clinicedc/edc-model-admin"
},
"split_keywords": [
"django",
"modeladmin",
"edc",
"clinicedc",
"clinical",
"trials"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ebe1da7dd01000f31f7a280c2aec791635bd929eb1b8354e1b675fec37232795",
"md5": "5c7c8a40974aa2d47bf7a31ca46fcdfa",
"sha256": "798fdf565fcf1b680b7623e89871ded6b66b5f762fdad465e0d2b4368b8a52d7"
},
"downloads": -1,
"filename": "edc_model_admin-0.3.80-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5c7c8a40974aa2d47bf7a31ca46fcdfa",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 93596,
"upload_time": "2024-11-26T22:27:28",
"upload_time_iso_8601": "2024-11-26T22:27:28.123596Z",
"url": "https://files.pythonhosted.org/packages/eb/e1/da7dd01000f31f7a280c2aec791635bd929eb1b8354e1b675fec37232795/edc_model_admin-0.3.80-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0dd5b375db2328f6ea68b8c63061e4702bbd4a09519b76c8a98cee6d3b416d43",
"md5": "46853dcc919e2446056ad3884c10a884",
"sha256": "feaedee5750966a5b3389b452e64dd4a090f9bc7e7b619c81fa43416c3cac31e"
},
"downloads": -1,
"filename": "edc_model_admin-0.3.80.tar.gz",
"has_sig": false,
"md5_digest": "46853dcc919e2446056ad3884c10a884",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 67289,
"upload_time": "2024-11-26T22:27:30",
"upload_time_iso_8601": "2024-11-26T22:27:30.441792Z",
"url": "https://files.pythonhosted.org/packages/0d/d5/b375db2328f6ea68b8c63061e4702bbd4a09519b76c8a98cee6d3b416d43/edc_model_admin-0.3.80.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-26 22:27:30",
"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"
}