Skip to content

Commit d726206

Browse files
Merge branch 'update/report-layout-consistency' into develop
2 parents b65b99b + 0a42f92 commit d726206

18 files changed

+266
-151
lines changed

effect_reports/admin/baseline_vl_admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
BaselineVlDiscrepancyDf,
1111
BaselineVlMissingQuantifierDf,
1212
)
13+
from ..modeladmin_mixins.baseline_vl_modeladmin_mixin import BaselineVlModelAdminMixin
1314
from ..models import BaselineVlAll, BaselineVlMissingQuantifier
14-
from .modeladmin_mixins import BaselineVlModelAdminMixin
1515

1616
if TYPE_CHECKING:
1717
from django.db.models import QuerySet

effect_reports/admin/modeladmin_mixins.py

Lines changed: 0 additions & 88 deletions
This file was deleted.

effect_reports/admin/serum_crag_date_admin/serum_crag_date_admin.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,31 @@
1010

1111
from ...admin_site import effect_reports_admin
1212
from ...dataframes import SerumCragDateDf
13+
from ...modeladmin_mixins import EffectReportModelAdminMixin
1314
from ...models import SerumCragDate
1415
from .list_filters import SerumCragDateNoteStatusListFilter
1516

1617

1718
@admin.register(SerumCragDate, site=effect_reports_admin)
1819
class SerumCragDateAdmin(
20+
EffectReportModelAdminMixin,
1921
QaReportModelAdminMixin,
2022
SiteModelAdminMixin,
2123
ModelAdminDashboardMixin,
2224
TemplatesModelAdminMixin,
2325
admin.ModelAdmin,
2426
):
25-
qa_report_list_display_insert_pos = 5
27+
qa_report_list_display_insert_pos = 4
28+
site_list_display_insert_pos = 1
2629
list_per_page = 25
2730
note_model = "effect_reports.serumcragdatenote"
2831
note_status_list_filter = SerumCragDateNoteStatusListFilter
2932

3033
ordering = ("subject_identifier",)
3134
list_display = [
32-
"dashboard",
33-
"subject",
34-
"screening",
35+
"subject_dashboard",
3536
"site",
37+
"screening",
3638
"serum_crag_date",
3739
"eligibility_date",
3840
"serum_crag_value",

effect_reports/admin/serum_crag_date_admin/serum_crag_date_note_admin.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616

1717
from ...admin_site import effect_reports_admin
1818
from ...forms import SerumCragDateNoteForm
19+
from ...modeladmin_mixins import EffectReportModelAdminMixin
1920
from ...models import SerumCragDateNote
2021

2122

2223
@admin.register(SerumCragDateNote, site=effect_reports_admin)
2324
class SerumCragDateNoteAdmin(
25+
EffectReportModelAdminMixin,
2426
SiteModelAdminMixin,
2527
ModelAdminDashboardMixin,
2628
ModelAdminAuditFieldsMixin,
@@ -66,8 +68,8 @@ class SerumCragDateNoteAdmin(
6668
)
6769

6870
list_display = [
69-
"dashboard",
70-
"subject_identifier",
71+
"subject_dashboard",
72+
"site",
7173
"report",
7274
"status",
7375
"serum_crag_date",
Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
from django.contrib import admin
2-
from django.core.exceptions import ObjectDoesNotExist
32
from django.template.loader import render_to_string
4-
from django.urls import reverse
53
from django.utils.html import format_html
64
from django.utils.safestring import mark_safe
7-
from django.utils.translation import gettext_lazy as _
8-
from edc_appointment.models import Appointment
95
from edc_model_admin.dashboard import ModelAdminDashboardMixin
106
from edc_model_admin.mixins import TemplatesModelAdminMixin
117
from edc_qareports.modeladmin_mixins import QaReportModelAdminMixin
128
from edc_sites.admin import SiteModelAdminMixin
139
from edc_visit_schedule.admin import ScheduleStatusListFilter
1410

1511
from ...admin_site import effect_reports_admin
12+
from ...modeladmin_mixins import CrfReportModelAdminMixin, EffectReportModelAdminMixin
1613
from ...models import Rm792KwInCurrentSxGteG3Other
1714

1815

1916
@admin.register(Rm792KwInCurrentSxGteG3Other, site=effect_reports_admin)
2017
class Rm792KwInCurrentSxGteG3OtherAdmin(
18+
CrfReportModelAdminMixin,
19+
EffectReportModelAdminMixin,
2120
QaReportModelAdminMixin,
2221
SiteModelAdminMixin,
2322
ModelAdminDashboardMixin,
2423
TemplatesModelAdminMixin,
2524
admin.ModelAdmin,
2625
):
26+
crf_model = "effect_subject.signsandsymptoms"
27+
qa_report_list_display_insert_pos = 4
28+
site_list_display_insert_pos = 2
2729
list_per_page = 25
30+
2831
change_list_note = format_html(
2932
"{html}",
3033
html=mark_safe(
@@ -37,9 +40,10 @@ class Rm792KwInCurrentSxGteG3OtherAdmin(
3740
ordering = ["site", "subject_identifier", "visit_code", "visit_code_sequence"]
3841

3942
list_display = [
40-
"dashboard",
43+
"subject_dashboard",
44+
"visit_dashboard",
4145
"site",
42-
"subject_identifier",
46+
"update_crf",
4347
"current_sx_gte_g3_other",
4448
"user_created",
4549
"user_modified",
@@ -56,25 +60,3 @@ class Rm792KwInCurrentSxGteG3OtherAdmin(
5660
]
5761

5862
search_fields = ["subject_identifier", "current_sx_gte_g3_other"]
59-
60-
def dashboard(self, obj=None, label=None) -> str:
61-
kwargs = self.get_subject_dashboard_url_kwargs(obj)
62-
try:
63-
kwargs.update(
64-
appointment=str(
65-
Appointment.objects.get(
66-
subject_identifier=obj.subject_identifier,
67-
visit_code=obj.visit_code,
68-
visit_code_sequence=obj.visit_code_sequence,
69-
).id
70-
)
71-
)
72-
except ObjectDoesNotExist:
73-
pass
74-
url = reverse(self.get_subject_dashboard_url_name(obj=obj), kwargs=kwargs)
75-
context = dict(
76-
title=_(f"Go to subject's dashboard@{obj.visit_code}.{obj.visit_code_sequence}"),
77-
url=url,
78-
label=_(f"Visit: {obj.visit_code}.{obj.visit_code_sequence}"),
79-
)
80-
return render_to_string("edc_subject_dashboard/dashboard_button.html", context=context)
Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
from django.contrib import admin
2-
from django.core.exceptions import ObjectDoesNotExist
32
from django.template.loader import render_to_string
4-
from django.urls import reverse
53
from django.utils.html import format_html
64
from django.utils.safestring import mark_safe
7-
from django.utils.translation import gettext_lazy as _
8-
from edc_appointment.models import Appointment
95
from edc_model_admin.dashboard import ModelAdminDashboardMixin
106
from edc_model_admin.mixins import TemplatesModelAdminMixin
117
from edc_qareports.modeladmin_mixins import QaReportModelAdminMixin
128
from edc_sites.admin import SiteModelAdminMixin
139
from edc_visit_schedule.admin import ScheduleStatusListFilter
1410

1511
from ...admin_site import effect_reports_admin
12+
from ...modeladmin_mixins import CrfReportModelAdminMixin, EffectReportModelAdminMixin
1613
from ...models import Rm792KwInCurrentSxOther
1714

1815

1916
@admin.register(Rm792KwInCurrentSxOther, site=effect_reports_admin)
2017
class Rm792KwInCurrentSxOtherAdmin(
18+
CrfReportModelAdminMixin,
19+
EffectReportModelAdminMixin,
2120
QaReportModelAdminMixin,
2221
SiteModelAdminMixin,
2322
ModelAdminDashboardMixin,
2423
TemplatesModelAdminMixin,
2524
admin.ModelAdmin,
2625
):
26+
crf_model = "effect_subject.signsandsymptoms"
27+
qa_report_list_display_insert_pos = 4
28+
site_list_display_insert_pos = 2
2729
list_per_page = 25
2830

2931
change_list_note = format_html(
@@ -36,9 +38,10 @@ class Rm792KwInCurrentSxOtherAdmin(
3638
ordering = ["site", "subject_identifier", "visit_code", "visit_code_sequence"]
3739

3840
list_display = [
39-
"dashboard",
41+
"subject_dashboard",
42+
"visit_dashboard",
4043
"site",
41-
"subject_identifier",
44+
"update_crf",
4245
"current_sx_other",
4346
"user_created",
4447
"user_modified",
@@ -55,25 +58,3 @@ class Rm792KwInCurrentSxOtherAdmin(
5558
]
5659

5760
search_fields = ["subject_identifier", "current_sx_other"]
58-
59-
def dashboard(self, obj=None, label=None) -> str:
60-
kwargs = self.get_subject_dashboard_url_kwargs(obj)
61-
try:
62-
kwargs.update(
63-
appointment=str(
64-
Appointment.objects.get(
65-
subject_identifier=obj.subject_identifier,
66-
visit_code=obj.visit_code,
67-
visit_code_sequence=obj.visit_code_sequence,
68-
).id
69-
)
70-
)
71-
except ObjectDoesNotExist:
72-
pass
73-
url = reverse(self.get_subject_dashboard_url_name(obj=obj), kwargs=kwargs)
74-
context = dict(
75-
title=_(f"Go to subject's dashboard@{obj.visit_code}.{obj.visit_code_sequence}"),
76-
url=url,
77-
label=_(f"Visit: {obj.visit_code}.{obj.visit_code_sequence}"),
78-
)
79-
return render_to_string("edc_subject_dashboard/dashboard_button.html", context=context)

effect_reports/dataframes/dataframe_mixins.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def to_dataframe(self) -> pd.DataFrame:
2121
"id",
2222
"subject_identifier",
2323
"site_id",
24+
"visit_code_str",
25+
"visit_code_sequence",
2426
"has_viral_load_result",
2527
"viral_load_result",
2628
"viral_load_quantifier",
@@ -47,6 +49,8 @@ def to_model(self, model: str | None = None) -> None:
4749
crf_id=row["id"],
4850
subject_identifier=row["subject_identifier"],
4951
site_id=row["site_id"],
52+
visit_code=row["visit_code_str"],
53+
visit_code_sequence=row["visit_code_sequence"],
5054
# data
5155
has_viral_load_result=row["has_viral_load_result"],
5256
viral_load_result=(
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Generated by Django 5.1.3 on 2025-01-23 11:46
2+
3+
from django.db import migrations
4+
from edc_qareports.utils import read_unmanaged_model_sql
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
("effect_reports", "0011_alter_baselinevldiscrepancy_options_and_more"),
11+
]
12+
13+
operations = [
14+
migrations.RunSQL("drop view if exists rm792_kw_in_current_sx_other"),
15+
migrations.RunSQL(
16+
read_unmanaged_model_sql(
17+
"rm792_kw_in_current_sx_other.sql",
18+
app_name="effect_reports",
19+
)
20+
),
21+
migrations.RunSQL("drop view if exists rm792_kw_in_current_sx_gte_g3_other"),
22+
migrations.RunSQL(
23+
read_unmanaged_model_sql(
24+
"rm792_kw_in_current_sx_gte_g3_other.sql",
25+
app_name="effect_reports",
26+
)
27+
),
28+
]

0 commit comments

Comments
 (0)