mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 13:05:42 +00:00
store methods on load
This commit is contained in:
@ -122,10 +122,18 @@ class BulkNotificationMethod(NotificationMethod):
|
||||
raise NotImplementedError('The `send` method must be overriden!')
|
||||
|
||||
|
||||
class MethodStorageClass:
|
||||
liste = None
|
||||
|
||||
def collect(self):
|
||||
storage.liste = inheritors(NotificationMethod) - IGNORED_NOTIFICATION_CLS
|
||||
|
||||
|
||||
IGNORED_NOTIFICATION_CLS = set([
|
||||
SingleNotificationMethod,
|
||||
BulkNotificationMethod,
|
||||
])
|
||||
storage = MethodStorageClass()
|
||||
|
||||
|
||||
class UIMessageNotification(SingleNotificationMethod):
|
||||
@ -190,9 +198,11 @@ def trigger_notifaction(obj, category=None, obj_ref='pk', **kwargs):
|
||||
|
||||
# Collect possible methods
|
||||
if delivery_methods is None:
|
||||
delivery_methods = inheritors(NotificationMethod)
|
||||
delivery_methods = storage.liste
|
||||
else:
|
||||
delivery_methods = (delivery_methods - IGNORED_NOTIFICATION_CLS)
|
||||
|
||||
for method in (delivery_methods - IGNORED_NOTIFICATION_CLS):
|
||||
for method in delivery_methods:
|
||||
logger.info(f"Triggering method '{method.METHOD_NAME}'")
|
||||
try:
|
||||
deliver_notification(method, obj, category, targets, context)
|
||||
|
Reference in New Issue
Block a user