Skip to content

Commit

Permalink
Merge branch 'release/0.3.73' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Jan 26, 2024
2 parents e081b3f + 1c7ffd6 commit bd726cb
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 31 deletions.
2 changes: 1 addition & 1 deletion edc_action_item/action_item_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.core.exceptions import ObjectDoesNotExist
from edc_constants.constants import CLOSED, NEW, OPEN
from edc_notification import Notification
from edc_notification.notification import Notification
from edc_utils import get_utcnow

NOTIFY_ON_NEW_AND_NO_REFERENCE_OBJ = "notify_on_new_and_no_reference_obj"
Expand Down
18 changes: 0 additions & 18 deletions edc_action_item/apps.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,11 @@
import sys

from django.apps import AppConfig as DjangoApponfig
from django.core.management.color import color_style
from django.db.models.signals import post_migrate

from .site_action_items import site_action_items

style = color_style()


def update_action_types(sender=None, verbose=None, **kwargs): # noqa
sys.stdout.write(style.MIGRATE_HEADING("Updating action types:\n"))
site_action_items.create_or_update_action_types()
sys.stdout.write("Done.\n")
sys.stdout.flush()


class AppConfig(DjangoApponfig):
name = "edc_action_item"
verbose_name = "Action Items"
has_exportable_data = True
include_in_administration_section = True

def ready(self):
post_migrate.connect(update_action_types, sender=self)
sys.stdout.write(f"Loading {self.verbose_name} ...\n")
site_action_items.autodiscover()
sys.stdout.write(f" Done loading {self.verbose_name}.\n")
2 changes: 1 addition & 1 deletion edc_action_item/auths.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from edc_auth.auth_objects import (
from edc_auth.constants import (
AUDITOR_ROLE,
CLINICIAN_ROLE,
CLINICIAN_SUPER_ROLE,
Expand Down
2 changes: 1 addition & 1 deletion edc_action_item/models/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.db.models.signals import m2m_changed, post_delete, post_save
from django.dispatch import receiver
from edc_constants.constants import CLOSED, NEW, OPEN
from edc_notification import site_notifications
from edc_notification.site_notifications import site_notifications
from simple_history.signals import post_create_historical_record

from ..utils import reset_and_delete_action_item
Expand Down
14 changes: 14 additions & 0 deletions edc_action_item/post_migrate_signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import sys

from django.core.management.color import color_style

style = color_style()


def update_action_types(sender=None, verbose=None, **kwargs): # noqa
from .site_action_items import site_action_items

sys.stdout.write(style.MIGRATE_HEADING("Updating action types:\n"))
site_action_items.create_or_update_action_types()
sys.stdout.write("Done.\n")
sys.stdout.flush()
8 changes: 5 additions & 3 deletions edc_action_item/site_action_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
from django.apps import apps as django_apps
from django.core.management.color import color_style
from django.utils.module_loading import module_has_submodule
from edc_notification import AlreadyRegistered as NotificationAlreadyRegistered
from edc_notification import site_notifications
from edc_notification.site_notifications import (
AlreadyRegistered as NotificationAlreadyRegistered,
)
from edc_notification.site_notifications import site_notifications
from edc_prn.prn import Prn
from edc_prn.site_prn_forms import AlreadyRegistered as PrnAlreadyRegistered
from edc_prn.site_prn_forms import site_prn_forms
Expand Down Expand Up @@ -154,7 +156,7 @@ def autodiscover(module_name=None, verbose=True):
try:
before_import_registry = copy.copy(site_action_items.registry)
import_module(f"{app}.{module_name}")
writer(f" * registered '{module_name}' from '{app}'\n")
writer(f" - registered '{module_name}' from '{app}'\n")
except SiteActionError as e:
writer(f" - loading {app}.{module_name} ... ")
writer(style.ERROR(f"ERROR! {e}\n"))
Expand Down
13 changes: 7 additions & 6 deletions edc_action_item/system_checks.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from django.core.checks import Warning, register
from django.core.checks import Warning

from edc_action_item.site_action_items import site_action_items
from .site_action_items import site_action_items


@register()
def edc_notification_check(app_configs, **kwargs): # noqa
def edc_action_item_check(app_configs, **kwargs):
errors = []

for action_cls in site_action_items.registry.items():
for name, action_cls in site_action_items.registry.items():
try:
action_cls.reference_model_cls().history
except AttributeError:
except AttributeError as e:
if "history" not in str(e):
raise
errors.append(
Warning(
(
Expand Down
2 changes: 2 additions & 0 deletions edc_action_item/tests/action_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from ..action import Action
from ..action_with_notification import ActionWithNotification
from ..models import ActionType
from ..site_action_items import site_action_items


Expand Down Expand Up @@ -150,6 +151,7 @@ class CrfLongitudinalOneAction(Action):


def register_actions():
ActionType.objects.all().delete()
site_action_items.registry = {}
site_action_items.register(FormZeroAction)
site_action_items.register(FormOneAction)
Expand Down
2 changes: 1 addition & 1 deletion edc_action_item/tests/tests/test_action_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.core import mail
from django.test import TestCase
from edc_constants.constants import NEW
from edc_notification import NewModelNotification, UpdatedModelNotification
from edc_notification.notification import NewModelNotification, UpdatedModelNotification
from edc_notification.site_notifications import site_notifications

from edc_action_item.action_item_notification import (
Expand Down
3 changes: 3 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"edc_auth.apps.AppConfig",
"edc_appointment.apps.AppConfig",
"edc_crf.apps.AppConfig",
"edc_data_manager.apps.AppConfig",
"edc_form_runners.apps.AppConfig",
"edc_facility.apps.AppConfig",
"edc_lab.apps.AppConfig",
"edc_navbar.apps.AppConfig",
Expand All @@ -53,6 +55,7 @@
"edc_visit_tracking.apps.AppConfig",
"edc_visit_schedule.apps.AppConfig",
"edc_action_item.apps.AppConfig",
"edc_appconfig.apps.AppConfig",
],
add_dashboard_middleware=True,
use_test_urls=True,
Expand Down

0 comments on commit bd726cb

Please sign in to comment.