2
0
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:
Matthias
2022-04-02 04:11:29 +02:00
parent 6a300ea24a
commit 926f56bb41
2 changed files with 39 additions and 6 deletions

View File

@ -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: