2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-09-15 23:21:32 +00:00

Added required attribute to settings/plugins, refactor: allValues (#5224)

* Added required attribute to settings/plugins, refactor: allValues

- added 'required' attribute to InvenTreeBaseSetting
- added 'check_all_settings'
- added 'all_settings' to get a list of all defined settings
- refactored 'allValues' to use new 'all_settings' function
- added docs for new 'check_setting' function on plugin SettingsMixin

* Fix typing to be compatible with python 3.9

* trigger: ci

* Fixed **kwargs bug and added tests
This commit is contained in:
Lukas
2023-07-12 00:19:19 +02:00
committed by GitHub
parent b3dcc28bd9
commit ee274739a6
6 changed files with 142 additions and 26 deletions

View File

@@ -84,3 +84,16 @@ class SettingsMixin:
return
PluginSetting.set_setting(key, value, user, plugin=plugin)
def check_settings(self):
"""Check if all required settings for this machine are defined.
Warning: This method cannot be used in the __init__ function of the plugin
Returns:
is_valid: Are all required settings defined
missing_settings: List of all settings that are missing (empty if is_valid is 'True')
"""
from plugin.models import PluginSetting
return PluginSetting.check_all_settings(settings_definition=self.settings, plugin=self.plugin_config())