From dceea757e1adf2ce337ada48c91ea1737e049204 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 4 Dec 2021 02:12:51 +0100 Subject: [PATCH] create a notification message! --- InvenTree/common/notifications.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/InvenTree/common/notifications.py b/InvenTree/common/notifications.py index bae6f6a763..86b9a922b1 100644 --- a/InvenTree/common/notifications.py +++ b/InvenTree/common/notifications.py @@ -7,7 +7,7 @@ from django.template.loader import render_to_string from allauth.account.models import EmailAddress from InvenTree.helpers import inheritors -from common.models import NotificationEntry +from common.models import NotificationEntry, NotificationMessage import InvenTree.tasks @@ -82,6 +82,22 @@ class EmailNotification(BulkNotificationMethod): InvenTree.tasks.send_email(context['template']['subject'], '', recipients, html_message=html_message) return True + +class UIMessageNotification(SingleNotificationMethod): + METHOD_NAME = 'ui_message' + + def get_recipients(self): + return self.receivers + + def send(self, receiver, context): + NotificationMessage.objects.create( + target_object = self.obj, + source_object = receiver, + user = receiver, + category = self.entry_name, + name = context['name'], + message = context['message'], + ) # endregion # endregion