mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-01 11:10:54 +00:00
Adds API endpoints for viewing and updating plugin settings
A lot of code updates / refactoring here to get this to work as expected
This commit is contained in:
@ -36,17 +36,14 @@ class SettingsMixin:
|
||||
|
||||
# Find the plugin configuration associated with this plugin
|
||||
|
||||
try:
|
||||
plugin, _ = PluginConfig.objects.get_or_create(key=self.plugin_slug(), name=self.plugin_name())
|
||||
except (OperationalError, ProgrammingError) as error:
|
||||
plugin = None
|
||||
|
||||
if not plugin:
|
||||
plugin = self.plugin_config()
|
||||
|
||||
if plugin:
|
||||
return PluginSetting.get_setting(key, plugin=plugin, settings=self.settings)
|
||||
else:
|
||||
# Plugin cannot be found, return default value
|
||||
return PluginSetting.get_setting_default(key, settings=self.settings)
|
||||
|
||||
return PluginSetting.get_setting(key, plugin=plugin, settings=self.settings)
|
||||
|
||||
def set_setting(self, key, value, user):
|
||||
"""
|
||||
Set plugin setting value by key
|
||||
@ -54,12 +51,12 @@ class SettingsMixin:
|
||||
|
||||
try:
|
||||
plugin, _ = PluginConfig.objects.get_or_create(key=self.plugin_slug(), name=self.plugin_name())
|
||||
except (OperationalError, ProgrammingError) as error:
|
||||
except (OperationalError, ProgrammingError):
|
||||
plugin = None
|
||||
|
||||
if not plugin:
|
||||
# Cannot find associated plugin model, return
|
||||
return
|
||||
return
|
||||
|
||||
PluginSetting.set_setting(key, value, user, plugin=plugin, settings=self.settings)
|
||||
|
||||
|
Reference in New Issue
Block a user