create a notification message!

This commit is contained in:
Matthias 2021-12-04 02:12:51 +01:00
parent c803fdaab1
commit dceea757e1
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -7,7 +7,7 @@ from django.template.loader import render_to_string
from allauth.account.models import EmailAddress from allauth.account.models import EmailAddress
from InvenTree.helpers import inheritors from InvenTree.helpers import inheritors
from common.models import NotificationEntry from common.models import NotificationEntry, NotificationMessage
import InvenTree.tasks import InvenTree.tasks
@ -82,6 +82,22 @@ class EmailNotification(BulkNotificationMethod):
InvenTree.tasks.send_email(context['template']['subject'], '', recipients, html_message=html_message) InvenTree.tasks.send_email(context['template']['subject'], '', recipients, html_message=html_message)
return True 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
# endregion # endregion