Skip to content

Commit

Permalink
Meta class / indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Dec 4, 2023
1 parent ff8019a commit db28a06
Show file tree
Hide file tree
Showing 13 changed files with 482 additions and 37 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ class AeFollowupModelMixin(

on_site = ActionIdentifierSiteManager()

class Meta:
class Meta(
SiteModelMixin.Meta, NonUniqueSubjectIdentifierFieldMixin.Meta, ActionModelMixin.Meta
):
abstract = True
verbose_name = "AE Follow-up Report"
indexes = [
models.Index(fields=["subject_identifier", "action_identifier", "site", "id"])
]
indexes = (
NonUniqueSubjectIdentifierFieldMixin.Meta.indexes
+ ActionModelMixin.Meta.indexes
+ [models.Index(fields=["subject_identifier", "action_identifier", "site", "id"])]
)
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ class AeInitialModelMixin(

on_site = ActionIdentifierSiteManager()

class Meta:
class Meta(NonUniqueSubjectIdentifierFieldMixin.Meta):
abstract = True
verbose_name = "AE Initial Report"
indexes = [
models.Index(fields=["subject_identifier", "action_identifier", "site", "id"])
]
indexes = (
NonUniqueSubjectIdentifierFieldMixin.Meta.indexes
+ ActionModelMixin.Meta.indexes
+ [models.Index(fields=["subject_identifier", "action_identifier", "site"])]
)
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ class AesiModelMixin(

on_site = ActionIdentifierSiteManager()

class Meta:
class Meta(NonUniqueSubjectIdentifierFieldMixin.Meta):
abstract = True
verbose_name = "AE of Special Interest Report"
indexes = [
models.Index(fields=["subject_identifier", "action_identifier", "site", "id"])
]
indexes = (
NonUniqueSubjectIdentifierFieldMixin.Meta.indexes
+ ActionModelMixin.Meta.indexes
+ [models.Index(fields=["subject_identifier", "action_identifier", "site", "id"])]
)
11 changes: 7 additions & 4 deletions edc_adverse_event/model_mixins/ae_susar/ae_susar_model_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ class AeSusarModelMixin(

on_site = ActionIdentifierSiteManager()

class Meta:
class Meta(NonUniqueSubjectIdentifierFieldMixin.Meta, ActionModelMixin.Meta):
abstract = True
verbose_name = "AE SUSAR Report"
indexes = [
models.Index(fields=["subject_identifier", "action_identifier", "site", "id"])
]
verbose_name_plural = "AE SUSAR Reports"
indexes = (
NonUniqueSubjectIdentifierFieldMixin.Meta.indexes
+ ActionModelMixin.Meta.indexes
+ [models.Index(fields=["subject_identifier", "action_identifier", "site", "id"])]
)
11 changes: 7 additions & 4 deletions edc_adverse_event/model_mixins/ae_tmg/ae_tmg_model_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ class AeTmgModelMixin(

on_site = ActionIdentifierSiteManager()

class Meta:
class Meta(NonUniqueSubjectIdentifierFieldMixin.Meta, ActionModelMixin.Meta):
abstract = True
verbose_name = "AE TMG Report"
indexes = [
models.Index(fields=["subject_identifier", "action_identifier", "site", "id"])
]
verbose_name_plural = "AE TMG Reports"
indexes = (
NonUniqueSubjectIdentifierFieldMixin.Meta.indexes
+ ActionModelMixin.Meta.indexes
+ [models.Index(fields=["subject_identifier", "action_identifier", "site", "id"])]
)
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,14 @@ def natural_key(self):

natural_key.dependencies = ["edc_adverse_event.causeofdeath"]

class Meta:
class Meta(
SiteModelMixin.Meta,
UniqueSubjectIdentifierFieldMixin.Meta,
ActionNoManagersModelMixin.Meta,
):
abstract = True
verbose_name = "Death Report"
indexes = [
verbose_name_plural = "Death Reports"
indexes = ActionNoManagersModelMixin.Meta.indexes + [
models.Index(fields=["subject_identifier", "action_identifier", "site", "id"])
]
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,19 @@ class DeathReportTmgModelMixin(

on_site = DeathReportTmgSiteManager()

class Meta:
class Meta(
SiteModelMixin.Meta,
NonUniqueSubjectIdentifierFieldMixin.Meta,
ActionModelMixin.Meta,
):
abstract = True
verbose_name = "Death Report TMG (1st)"
verbose_name_plural = "Death Report TMG (1st)"
indexes = [
models.Index(fields=["subject_identifier", "action_identifier", "site", "id"])
]
indexes = (
NonUniqueSubjectIdentifierFieldMixin.Meta.indexes
+ ActionModelMixin.Meta.indexes
+ [models.Index(fields=["subject_identifier", "action_identifier", "site", "id"])]
)


class DeathReportTmgSecondModelMixin(DeathReportTmgModelMixin):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django.db import models
from edc_action_item.managers import (
ActionIdentifierModelManager,
ActionIdentifierSiteManager,
Expand Down Expand Up @@ -27,10 +26,8 @@ class DeathReportTmgSecondModelMixin(DeathReportTmgModelMixin):

on_site = DeathReportTmgSecondSiteManager()

class Meta:
class Meta(DeathReportTmgModelMixin.Meta):
abstract = True
verbose_name = "Death Report TMG (2nd)"
verbose_name_plural = "Death Report TMG (2nd)"
indexes = [
models.Index(fields=["subject_identifier", "action_identifier", "site", "id"])
]
indexes = DeathReportTmgModelMixin.Meta.indexes
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ class SimpleDeathReportModelMixin(
def natural_key(self):
return (self.action_identifier,)

class Meta:
class Meta(ActionModelMixin.Meta):
abstract = True
verbose_name = "Death Report"
verbose_name_plural = "Death Reports"
indexes = [
indexes = ActionModelMixin.Meta.indexes + [
models.Index(fields=["subject_identifier", "action_identifier", "site", "id"])
]
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class HospitalizationModelMixin(NonUniqueSubjectIdentifierFieldMixin, models.Mod
blank=True,
)

class Meta:
class Meta(NonUniqueSubjectIdentifierFieldMixin.Meta):
abstract = True
verbose_name = "Hospitalization"
verbose_name_plural = "Hospitalization"
indexes = NonUniqueSubjectIdentifierFieldMixin.Meta.indexes
2 changes: 1 addition & 1 deletion edc_adverse_event/models/edc_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
class EdcPermissions(EdcPermissionsModelMixin, BaseUuidModel):
# see edc_auth for permissions attached to this model

class Meta(EdcPermissionsModelMixin.Meta):
class Meta(EdcPermissionsModelMixin.Meta, BaseUuidModel.Meta):
pass
4 changes: 2 additions & 2 deletions edc_adverse_event/tests/tests/test_ae_and_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from edc_ltfu.constants import LOST_TO_FOLLOWUP
from edc_registration.models import RegisteredSubject
from edc_reportable import GRADE5
from edc_sites import InvalidSiteForSubjectError
from edc_sites.valid_site_for_subject_or_raise import InvalidSubjectError
from edc_utils import get_utcnow
from edc_visit_schedule.utils import OnScheduleError
from model_bakery import baker
Expand Down Expand Up @@ -53,7 +53,7 @@ def test_subject_identifier(self):
)

self.assertRaises(
InvalidSiteForSubjectError,
InvalidSubjectError,
baker.make_recipe,
"adverse_event_app.aeinitial",
subject_identifier="blahblah",
Expand Down

0 comments on commit db28a06

Please sign in to comment.