Skip to content

Commit

Permalink
Stop sending around MEDIA_CLASSES
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed Jan 21, 2025
1 parent c164d5d commit 510f168
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/argus/notificationprofile/media/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@

# TODO: Raise Incident if media_class not importable?
MEDIA_PLUGINS = getattr(settings, "MEDIA_PLUGINS")
MEDIA_CLASSES = [import_class_from_dotted_path(media_plugin) for media_plugin in MEDIA_PLUGINS]
MEDIA_CLASSES_DICT = {media_class.MEDIA_SLUG: media_class for media_class in MEDIA_CLASSES}
_media_classes = [import_class_from_dotted_path(media_plugin) for media_plugin in MEDIA_PLUGINS]
MEDIA_CLASSES_DICT = {media_class.MEDIA_SLUG: media_class for media_class in _media_classes}


def api_safely_get_medium_object(media_slug):
Expand Down
4 changes: 2 additions & 2 deletions src/argus/notificationprofile/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def sync_media(sender, **kwargs):
Check if all media in Media has a respective class"""

from .media import MEDIA_CLASSES, MEDIA_CLASSES_DICT
from .media import MEDIA_CLASSES_DICT

apps = kwargs["apps"]
try:
Expand All @@ -42,7 +42,7 @@ def sync_media(sender, **kwargs):
# Check if all media plugins are also saved in Media
new_media = [
Media(slug=media_class.MEDIA_SLUG, name=media_class.MEDIA_NAME)
for media_class in MEDIA_CLASSES
for media_class in MEDIA_CLASSES_DICT.values()
if not Media.objects.filter(slug=media_class.MEDIA_SLUG)
]
if new_media:
Expand Down

0 comments on commit 510f168

Please sign in to comment.