mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
mkae user setting access simpler
This commit is contained in:
parent
547c51b81b
commit
4c1a0ea9ce
@ -114,6 +114,12 @@ class NotificationMethod:
|
||||
|
||||
# Lets go!
|
||||
return False
|
||||
|
||||
def usersetting(self, target):
|
||||
"""
|
||||
Returns setting for this method for a given user
|
||||
"""
|
||||
return NotificationUserSetting.get_setting(f'NOTIFICATION_METHOD_{self.METHOD_NAME.upper()}', user=target, method=self.METHOD_NAME)
|
||||
# endregion
|
||||
|
||||
|
||||
@ -220,7 +226,7 @@ def trigger_notifaction(obj, category=None, obj_ref='pk', **kwargs):
|
||||
|
||||
if NotificationEntry.check_recent(category, obj_ref_value, delta):
|
||||
logger.info(f"Notification '{category}' has recently been sent for '{str(obj)}' - SKIPPING")
|
||||
return
|
||||
# return
|
||||
|
||||
logger.info(f"Gathering users for notification '{category}'")
|
||||
# Collect possible targets
|
||||
|
@ -7,7 +7,6 @@ from allauth.account.models import EmailAddress
|
||||
|
||||
from plugin import IntegrationPluginBase
|
||||
from plugin.mixins import BulkNotificationMethod, SettingsMixin
|
||||
from plugin.models import NotificationUserSetting
|
||||
import InvenTree.tasks
|
||||
|
||||
|
||||
@ -59,7 +58,7 @@ class CoreNotificationsPlugin(SettingsMixin, IntegrationPluginBase):
|
||||
allowed_users = []
|
||||
|
||||
for user in self.targets:
|
||||
allows_emails = NotificationUserSetting.get_setting('NOTIFICATION_METHOD_MAIL', user=user, method=self.METHOD_NAME)
|
||||
allows_emails = self.usersetting(user)
|
||||
|
||||
if allows_emails:
|
||||
allowed_users.append(user)
|
||||
|
Loading…
Reference in New Issue
Block a user