mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
added setup function to notification method
and added calls to deliver_method
This commit is contained in:
parent
803936130c
commit
1b9ca41b46
@ -34,6 +34,9 @@ class NotificationMethod:
|
|||||||
def get_recipients(self):
|
def get_recipients(self):
|
||||||
raise NotImplementedError('The `get_recipients` method must be implemented!')
|
raise NotImplementedError('The `get_recipients` method must be implemented!')
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
return True
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -136,6 +139,9 @@ def deliver_notification(cls: NotificationMethod, obj, entry_name: str, receiver
|
|||||||
# 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)}'")
|
||||||
|
|
||||||
|
# Run setup for delivery method
|
||||||
|
method.setup()
|
||||||
|
|
||||||
success = True
|
success = True
|
||||||
success_count = 0
|
success_count = 0
|
||||||
|
|
||||||
@ -154,6 +160,9 @@ def deliver_notification(cls: NotificationMethod, obj, entry_name: str, receiver
|
|||||||
else:
|
else:
|
||||||
raise NotImplementedError('No delivery method found')
|
raise NotImplementedError('No delivery method found')
|
||||||
|
|
||||||
|
# Run cleanup for delivery method
|
||||||
|
method.cleanup()
|
||||||
|
|
||||||
# Log results
|
# Log results
|
||||||
logger.info(f"Notified {success_count} users via '{method.method_name}' for notification '{entry_name}' for '{str(obj)}' successfully")
|
logger.info(f"Notified {success_count} users via '{method.method_name}' for notification '{entry_name}' for '{str(obj)}' successfully")
|
||||||
if not success:
|
if not success:
|
||||||
|
Loading…
Reference in New Issue
Block a user