mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 21:15:41 +00:00
Merge pull request #2805 from matmair/matmair/issue2385
Plugins for notifications
This commit is contained in:
@ -28,7 +28,7 @@ import InvenTree.helpers
|
||||
from common.models import InvenTreeSetting, ColorTheme, InvenTreeUserSetting
|
||||
from common.settings import currency_code_default
|
||||
|
||||
from plugin.models import PluginSetting
|
||||
from plugin.models import PluginSetting, NotificationUserSetting
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@ -313,6 +313,9 @@ def setting_object(key, *args, **kwargs):
|
||||
|
||||
return PluginSetting.get_setting_object(key, plugin=plugin)
|
||||
|
||||
if 'method' in kwargs:
|
||||
return NotificationUserSetting.get_setting_object(key, user=kwargs['user'], method=kwargs['method'])
|
||||
|
||||
if 'user' in kwargs:
|
||||
return InvenTreeUserSetting.get_setting_object(key, user=kwargs['user'])
|
||||
|
||||
@ -326,6 +329,8 @@ def settings_value(key, *args, **kwargs):
|
||||
"""
|
||||
|
||||
if 'user' in kwargs:
|
||||
if not kwargs['user']:
|
||||
return InvenTreeUserSetting.get_setting(key)
|
||||
return InvenTreeUserSetting.get_setting(key, user=kwargs['user'])
|
||||
|
||||
return InvenTreeSetting.get_setting(key)
|
||||
|
@ -20,6 +20,7 @@ import part.settings
|
||||
|
||||
from InvenTree import version
|
||||
from common.models import InvenTreeSetting, NotificationEntry, NotificationMessage
|
||||
from common.notifications import storage, UIMessageNotification
|
||||
|
||||
|
||||
class TemplateTagTest(TestCase):
|
||||
@ -565,8 +566,15 @@ class BaseNotificationIntegrationTest(TestCase):
|
||||
# Define part that will be tested
|
||||
self.part = Part.objects.get(name='R_2K2_0805')
|
||||
|
||||
def _notification_run(self):
|
||||
# There should be no notification runs
|
||||
def _notification_run(self, run_class=None):
|
||||
"""
|
||||
Run a notification test suit through.
|
||||
If you only want to test one class pass it to run_class
|
||||
"""
|
||||
# reload notification methods
|
||||
storage.collect(run_class)
|
||||
|
||||
# There should be no notification runs
|
||||
self.assertEqual(NotificationEntry.objects.all().count(), 0)
|
||||
|
||||
# Test that notifications run through without errors
|
||||
@ -588,7 +596,7 @@ class PartNotificationTest(BaseNotificationIntegrationTest):
|
||||
""" Integration test for part notifications """
|
||||
|
||||
def test_notification(self):
|
||||
self._notification_run()
|
||||
self._notification_run(UIMessageNotification)
|
||||
|
||||
# There should be 1 notification message right now
|
||||
self.assertEqual(NotificationMessage.objects.all().count(), 1)
|
||||
|
Reference in New Issue
Block a user