From e95cc7c699bbdf1ad8b9819be2317eaa27abcf61 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 2 Apr 2022 02:57:40 +0200 Subject: [PATCH] only calculate excluded classes once --- InvenTree/common/notifications.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/InvenTree/common/notifications.py b/InvenTree/common/notifications.py index a733e191c8..103a070542 100644 --- a/InvenTree/common/notifications.py +++ b/InvenTree/common/notifications.py @@ -91,6 +91,12 @@ class BulkNotificationMethod(NotificationMethod): raise NotImplementedError('The `send` method must be overriden!') +IGNORED_NOTIFICATION_CLS = set([ + SingleNotificationMethod, + BulkNotificationMethod, +]) + + class UIMessageNotification(SingleNotificationMethod): METHOD_NAME = 'ui_message' @@ -155,11 +161,7 @@ def trigger_notifaction(obj, category=None, obj_ref='pk', **kwargs): if delivery_methods is None: delivery_methods = inheritors(NotificationMethod) - ignored_classes = set([ - SingleNotificationMethod, - BulkNotificationMethod, - ]) - for method in (delivery_methods - ignored_classes): + for method in (delivery_methods - IGNORED_NOTIFICATION_CLS): logger.info(f"Triggering method '{method.METHOD_NAME}'") try: deliver_notification(method, obj, category, targets, context)