mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
spell fixing
This commit is contained in:
parent
61b6590f52
commit
7ed18c1bfd
@ -28,11 +28,11 @@ class NotificationMethod:
|
|||||||
self.entry_name = entry_name
|
self.entry_name = entry_name
|
||||||
self.receiers = receivers
|
self.receiers = receivers
|
||||||
|
|
||||||
# gather recipiends
|
# gather recipients
|
||||||
self.recipiends = self.get_recipiends()
|
self.recipients = self.get_recipients()
|
||||||
|
|
||||||
def get_recipiends(self):
|
def get_recipients(self):
|
||||||
raise NotImplementedError('The `get_recipiends` method must be implemented!')
|
raise NotImplementedError('The `get_recipients` method must be implemented!')
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
return True
|
return True
|
||||||
@ -53,7 +53,7 @@ class BulkNotificationMethod(NotificationMethod):
|
|||||||
class EmailNotification(BulkNotificationMethod):
|
class EmailNotification(BulkNotificationMethod):
|
||||||
method_name = 'mail'
|
method_name = 'mail'
|
||||||
|
|
||||||
def get_recipiends(self):
|
def get_recipients(self):
|
||||||
return EmailAddress.objects.filter(
|
return EmailAddress.objects.filter(
|
||||||
user__in=self.receiers,
|
user__in=self.receiers,
|
||||||
)
|
)
|
||||||
@ -69,7 +69,7 @@ class EmailNotification(BulkNotificationMethod):
|
|||||||
raise NotImplementedError("template['subject'] must be provided in the `context`")
|
raise NotImplementedError("template['subject'] must be provided in the `context`")
|
||||||
|
|
||||||
html_message = render_to_string(context['template']['html'], context)
|
html_message = render_to_string(context['template']['html'], context)
|
||||||
recipients = self.recipiends.values_list('email', flat=True)
|
recipients = self.recipients.values_list('email', flat=True)
|
||||||
|
|
||||||
InvenTree.tasks.send_email(context['template']['subject'], '', recipients, html_message=html_message)
|
InvenTree.tasks.send_email(context['template']['subject'], '', recipients, html_message=html_message)
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ def deliver_notification(cls: NotificationMethod, obj, entry_name: str, receiver
|
|||||||
# Init delivery method
|
# Init delivery method
|
||||||
method = cls(obj, entry_name, receivers)
|
method = cls(obj, entry_name, receivers)
|
||||||
|
|
||||||
if method.recipiends and method.recipiends.count() > 0:
|
if method.recipients and method.recipients.count() > 0:
|
||||||
# Log start
|
# Log start
|
||||||
logger.info(f"Notify users via '{method.method_name}' for notification '{entry_name}' for '{str(obj)}'")
|
logger.info(f"Notify users via '{method.method_name}' for notification '{entry_name}' for '{str(obj)}'")
|
||||||
|
|
||||||
@ -142,10 +142,10 @@ def deliver_notification(cls: NotificationMethod, obj, entry_name: str, receiver
|
|||||||
# Select delivery method and execute it
|
# Select delivery method and execute it
|
||||||
if hasattr(method, 'send_bulk'):
|
if hasattr(method, 'send_bulk'):
|
||||||
success = method.send_bulk(notification_context)
|
success = method.send_bulk(notification_context)
|
||||||
success_count = method.recipiends.count()
|
success_count = method.recipients.count()
|
||||||
|
|
||||||
elif hasattr(method, 'send'):
|
elif hasattr(method, 'send'):
|
||||||
for rec in method.recipiends:
|
for rec in method.recipients:
|
||||||
if method.send(rec, notification_context):
|
if method.send(rec, notification_context):
|
||||||
success_count += 1
|
success_count += 1
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user