Registry name fixes

This commit is contained in:
Oliver 2021-12-31 14:28:16 +11:00
parent 02e0ea6e3a
commit 4b4d4be13e
3 changed files with 8 additions and 14 deletions

View File

@ -17,14 +17,8 @@ class SettingsMixin:
def __init__(self):
super().__init__()
self.add_mixin('globalsettings', 'has_globalsettings', __class__)
self.globalsettings = self.setup_globalsettings()
def setup_globalsettings(self):
"""
Setup global settings for this plugin
"""
return getattr(self, 'SETTINGS', None)
self.add_mixin('settings', 'has_globalsettings', __class__)
self.globalsettings = getattr(self, 'SETTINGS', None)
@property
def has_globalsettings(self):

View File

@ -251,7 +251,7 @@ class Plugins:
if settings.PLUGIN_TESTING or InvenTreeSetting.get_setting('ENABLE_PLUGINS_GLOBALSETTING'):
logger.info('Registering IntegrationPlugin global settings')
for slug, plugin in plugins:
if plugin.mixin_enabled('globalsettings'):
if plugin.mixin_enabled('settings'):
plugin_setting = plugin.globalsettingspatterns
self.mixins_globalsettings[slug] = plugin_setting

View File

@ -8,7 +8,7 @@ from django.contrib.auth import get_user_model
from datetime import datetime
from plugin import IntegrationPluginBase
from plugin.mixins import AppMixin, GlobalSettingsMixin, UrlsMixin, NavigationMixin
from plugin.mixins import AppMixin, SettingsMixin, UrlsMixin, NavigationMixin
from plugin.urls import PLUGIN_BASE
@ -20,19 +20,19 @@ class BaseMixinDefinition:
self.assertEqual(self.mixin.registered_mixins[0]['human_name'], self.MIXIN_HUMAN_NAME)
class GlobalSettingsMixinTest(BaseMixinDefinition, TestCase):
class SettingsMixinTest(BaseMixinDefinition, TestCase):
MIXIN_HUMAN_NAME = 'Settings'
MIXIN_NAME = 'globalsettings'
MIXIN_NAME = 'settings'
MIXIN_ENABLE_CHECK = 'has_globalsettings'
TEST_SETTINGS = {'SETTING1': {'default': '123', }}
def setUp(self):
class SettingsCls(GlobalSettingsMixin, IntegrationPluginBase):
class SettingsCls(SettingsMixin, IntegrationPluginBase):
GLOBALSETTINGS = self.TEST_SETTINGS
self.mixin = SettingsCls()
class NoSettingsCls(GlobalSettingsMixin, IntegrationPluginBase):
class NoSettingsCls(SettingsMixin, IntegrationPluginBase):
pass
self.mixin_nothing = NoSettingsCls()