Only send printing failed as a UI notification

This commit is contained in:
Oliver 2022-03-25 16:05:35 +11:00
parent c1b408f8a3
commit 9046c74628
2 changed files with 11 additions and 2 deletions

View File

@ -154,11 +154,18 @@ class UIMessageNotification(SingleNotificationMethod):
return True
def trigger_notifaction(obj, category=None, obj_ref='pk', targets=None, target_fnc=None, target_args=[], target_kwargs={}, context={}):
def trigger_notifaction(obj, category=None, obj_ref='pk', **kwargs):
"""
Send out a notification
"""
targets = kwargs.get('targets', None)
target_fnc = kwargs.get('target_fnc', None)
target_args = kwargs.get('target_args', [])
target_kwargs = kwargs.get('target_kwargs', {})
context = kwargs.get('context', {})
delivery_methods = kwargs.get('delivery_methods', None)
# Check if data is importing currently
if isImportingData():
return
@ -190,7 +197,8 @@ def trigger_notifaction(obj, category=None, obj_ref='pk', targets=None, target_f
logger.info(f"Sending notification '{category}' for '{str(obj)}'")
# Collect possible methods
delivery_methods = inheritors(NotificationMethod)
if delivery_methods is None:
delivery_methods = inheritors(NotificationMethod)
for method in [a for a in delivery_methods if a not in [SingleNotificationMethod, BulkNotificationMethod]]:
logger.info(f"Triggering method '{method.METHOD_NAME}'")

View File

@ -233,4 +233,5 @@ def print_label(plugin_slug, label_image, label_instance=None, user=None):
'label.printing_failed',
targets=[user],
context=ctx,
delivery_methods=[common.notifications.UIMessageNotification]
)