mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
create a notification message!
This commit is contained in:
parent
c803fdaab1
commit
dceea757e1
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user