diff --git a/InvenTree/plugin/builtin/integration/core_notifications.py b/InvenTree/plugin/builtin/integration/core_notifications.py index f21fe33703..3d5ce06cb6 100644 --- a/InvenTree/plugin/builtin/integration/core_notifications.py +++ b/InvenTree/plugin/builtin/integration/core_notifications.py @@ -7,7 +7,7 @@ from allauth.account.models import EmailAddress from plugin import IntegrationPluginBase from plugin.mixins import BulkNotificationMethod, SettingsMixin -from common.models import InvenTreeUserSetting +from plugin.models import NotificationUserSetting import InvenTree.tasks @@ -59,7 +59,7 @@ class CoreNotificationsPlugin(SettingsMixin, IntegrationPluginBase): allowed_users = [] for user in self.targets: - allows_emails = InvenTreeUserSetting.get_setting('NOTIFICATION_SEND_EMAILS', user=user) + allows_emails = NotificationUserSetting.get_setting('NOTIFICATION_METHOD_MAIL', user=user, method=self.METHOD_NAME) if allows_emails: allowed_users.append(user) diff --git a/InvenTree/plugin/builtin/integration/test_core_notifications.py b/InvenTree/plugin/builtin/integration/test_core_notifications.py new file mode 100644 index 0000000000..a65c36eca2 --- /dev/null +++ b/InvenTree/plugin/builtin/integration/test_core_notifications.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from allauth.account.models import EmailAddress + +from plugin.models import NotificationUserSetting +from part.test_part import BaseNotificationIntegrationTest +from plugin.builtin.integration.core_notifications import CoreNotificationsPlugin +from plugin import registry + + +class CoreNotificationTestTests(BaseNotificationIntegrationTest): + + def test_email(self): + """ + Ensure that the email notifications run + """ + + # enable plugin and set mail setting to true + plugin = registry.plugins.get('corenotificationsplugin') + plugin.set_setting('ENABLE_NOTIFICATION_EMAILS', True) + NotificationUserSetting.set_setting( + key='NOTIFICATION_METHOD_MAIL', + value=True, + change_user=self.user, + user=self.user, + method=CoreNotificationsPlugin.EmailNotification.METHOD_NAME + ) + + # run through + self._notification_run(CoreNotificationsPlugin.EmailNotification)