diff --git a/edc_data_manager/admin/autocomplete_admin.py b/edc_data_manager/admin/autocomplete_admin.py index 4434532..db0b126 100644 --- a/edc_data_manager/admin/autocomplete_admin.py +++ b/edc_data_manager/admin/autocomplete_admin.py @@ -4,7 +4,7 @@ from edc_auth.admin import UserAdmin as BaseUserAdmin from edc_lab.admin import PanelAdmin as BasePanelAdmin from edc_model_admin.mixins import TemplatesModelAdminMixin -from edc_registration.admin import RegisteredSubjectAdmin as BaseRegisteredSubjectAdmin +from edc_sites.admin import SiteModelAdminMixin from edc_visit_schedule.admin import VisitScheduleAdmin as BaseVisitScheduleAdmin from ..admin_site import edc_data_manager_admin @@ -40,7 +40,7 @@ class RequisitionDataDictionaryAdmin(TemplatesModelAdminMixin, admin.ModelAdmin) @register(QuerySubject, site=edc_data_manager_admin) -class QuerySubjectAdmin(BaseRegisteredSubjectAdmin): +class QuerySubjectAdmin(SiteModelAdminMixin, admin.ModelAdmin): ordering = ("subject_identifier",) search_fields = ("subject_identifier",) diff --git a/edc_data_manager/admin/data_query_admin.py b/edc_data_manager/admin/data_query_admin.py index 424f40a..b6b98ef 100644 --- a/edc_data_manager/admin/data_query_admin.py +++ b/edc_data_manager/admin/data_query_admin.py @@ -23,21 +23,19 @@ from edc_dashboard.utils import get_bootstrap_version from edc_model_admin.dashboard import ModelAdminSubjectDashboardMixin from edc_model_admin.history import SimpleHistoryAdmin +from edc_sites.admin import SiteModelAdminMixin from edc_utils import formatted_datetime from ..admin_site import edc_data_manager_admin from ..auth_objects import DATA_MANAGER from ..constants import CLOSED_WITH_ACTION from ..forms import DataQueryForm -from ..modeladmin_mixins import DataManagerSiteModelAdminMixin from ..models import DataDictionary, DataQuery from .actions import toggle_dm_status @register(DataQuery, site=edc_data_manager_admin) -class DataQueryAdmin( - DataManagerSiteModelAdminMixin, ModelAdminSubjectDashboardMixin, SimpleHistoryAdmin -): +class DataQueryAdmin(SiteModelAdminMixin, ModelAdminSubjectDashboardMixin, SimpleHistoryAdmin): status_column_template_name = ( f"edc_data_manager/bootstrap{get_bootstrap_version()}/columns/status.html" ) diff --git a/edc_data_manager/migrations/0028_alter_dataquery_options_alter_queryrule_options_and_more.py b/edc_data_manager/migrations/0028_alter_dataquery_options_alter_queryrule_options_and_more.py new file mode 100644 index 0000000..177dc47 --- /dev/null +++ b/edc_data_manager/migrations/0028_alter_dataquery_options_alter_queryrule_options_and_more.py @@ -0,0 +1,57 @@ +# Generated by Django 4.2.1 on 2023-07-05 02:16 + +from django.db import migrations +import django.db.models.manager +import edc_sites.model_mixins + + +class Migration(migrations.Migration): + dependencies = [ + ("edc_data_manager", "0027_alter_dataquery_dm_user"), + ] + + operations = [ + migrations.AlterModelOptions( + name="dataquery", + options={ + "default_manager_name": "objects", + "default_permissions": ( + "add", + "change", + "delete", + "view", + "export", + "import", + ), + "get_latest_by": "modified", + "ordering": ("-modified", "-created"), + "verbose_name": "Data Query", + "verbose_name_plural": "Data Queries", + }, + ), + migrations.AlterModelOptions( + name="queryrule", + options={ + "default_manager_name": "objects", + "default_permissions": ( + "add", + "change", + "delete", + "view", + "export", + "import", + ), + "get_latest_by": "modified", + "ordering": ("title",), + "verbose_name": "Query Rule", + "verbose_name_plural": "Query Rules", + }, + ), + migrations.AlterModelManagers( + name="dataquery", + managers=[ + ("on_site", edc_sites.model_mixins.CurrentSiteManager()), + ("objects", django.db.models.manager.Manager()), + ], + ), + ] diff --git a/edc_data_manager/migrations/0029_alter_dataquery_managers.py b/edc_data_manager/migrations/0029_alter_dataquery_managers.py new file mode 100644 index 0000000..7de92c8 --- /dev/null +++ b/edc_data_manager/migrations/0029_alter_dataquery_managers.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.1 on 2023-07-07 19:32 + +from django.db import migrations +import django.db.models.manager +import edc_sites.model_mixins + + +class Migration(migrations.Migration): + dependencies = [ + ( + "edc_data_manager", + "0028_alter_dataquery_options_alter_queryrule_options_and_more", + ), + ] + + operations = [ + migrations.AlterModelManagers( + name="dataquery", + managers=[ + ("objects", django.db.models.manager.Manager()), + ("on_site", edc_sites.model_mixins.CurrentSiteManager()), + ], + ), + ] diff --git a/edc_data_manager/modeladmin_mixins.py b/edc_data_manager/modeladmin_mixins.py index f834bf1..21014b9 100644 --- a/edc_data_manager/modeladmin_mixins.py +++ b/edc_data_manager/modeladmin_mixins.py @@ -1,12 +1,18 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + from django.conf import settings from django.contrib import messages -from django.contrib.admin import ModelAdmin from django.contrib.messages import get_messages from django.utils.html import format_html from django.utils.safestring import mark_safe from .auth_objects import DATA_MANAGER_ROLE +if TYPE_CHECKING: + from django.contrib.admin import ModelAdmin + class DataManagerSiteModelAdminMixin: """Do not declare together with `SiteModelAdminMixin`""" diff --git a/edc_data_manager/models/data_query.py b/edc_data_manager/models/data_query.py index 0b4d1d2..736d50f 100644 --- a/edc_data_manager/models/data_query.py +++ b/edc_data_manager/models/data_query.py @@ -90,10 +90,10 @@ class DataQuery(DataQueryModelMixin, ActionModelMixin, SiteModelMixin, BaseUuidM verbose_name="Query rule reference", max_length=150, null=True, default=uuid4 ) - on_site = CurrentSiteManager() - objects = models.Manager() + on_site = CurrentSiteManager() + def __str__(self): return f"{self.action_identifier[-9:]}, {self.status}"