mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-01 03:00:54 +00:00
move plugins checks to method
This commit is contained in:
@ -11,6 +11,11 @@ from common.models import InvenTreeUserSetting
|
||||
import InvenTree.tasks
|
||||
|
||||
|
||||
class PlgMixin:
|
||||
def get_plugin(self):
|
||||
return CoreNotificationsPlugin
|
||||
|
||||
|
||||
class CoreNotificationsPlugin(SettingsMixin, IntegrationPluginBase):
|
||||
"""
|
||||
Core notification methods for InvenTree
|
||||
@ -29,13 +34,15 @@ class CoreNotificationsPlugin(SettingsMixin, IntegrationPluginBase):
|
||||
},
|
||||
}
|
||||
|
||||
class EmailNotification(BulkNotificationMethod):
|
||||
class EmailNotification(PlgMixin, BulkNotificationMethod):
|
||||
METHOD_NAME = 'mail'
|
||||
CONTEXT_EXTRA = [
|
||||
('template', ),
|
||||
('template', 'html', ),
|
||||
('template', 'subject', ),
|
||||
]
|
||||
GLOBAL_SETTING = 'ENABLE_NOTIFICATION_EMAILS'
|
||||
}
|
||||
|
||||
def get_targets(self):
|
||||
"""
|
||||
@ -43,11 +50,6 @@ class CoreNotificationsPlugin(SettingsMixin, IntegrationPluginBase):
|
||||
only for users which allow email notifications
|
||||
"""
|
||||
|
||||
# Check if method globally enabled
|
||||
plg = registry.plugins.get(CoreNotificationsPlugin.PLUGIN_NAME.lower())
|
||||
if plg and not plg.get_setting('ENABLE_NOTIFICATION_EMAILS'):
|
||||
return
|
||||
|
||||
allowed_users = []
|
||||
|
||||
for user in self.targets:
|
||||
|
Reference in New Issue
Block a user