diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index 048a968d1a..16d0be035a 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -371,23 +371,14 @@ class BaseInvenTreeSetting(models.Model): validator = self.__class__.get_setting_validator(self.key, **kwargs) - if self.is_bool(): - self.value = InvenTree.helpers.str2bool(self.value) - - if self.is_int(): - try: - self.value = int(self.value) - except (ValueError): - raise ValidationError(_('Must be an integer value')) + if validator is not None: + self.run_validator(validator) options = self.valid_options() if options and self.value not in options: raise ValidationError(_("Chosen value is not a valid option")) - if validator is not None: - self.run_validator(validator) - def run_validator(self, validator): """ Run a validator against the 'value' field for this InvenTreeSetting object. @@ -399,7 +390,7 @@ class BaseInvenTreeSetting(models.Model): value = self.value # Boolean validator - if self.is_bool(): + if validator is bool: # Value must "look like" a boolean value if InvenTree.helpers.is_bool(value): # Coerce into either "True" or "False" @@ -410,7 +401,7 @@ class BaseInvenTreeSetting(models.Model): }) # Integer validator - if self.is_int(): + if validator is int: try: # Coerce into an integer value diff --git a/InvenTree/plugin/models.py b/InvenTree/plugin/models.py index f477df5c27..8b81eb2062 100644 --- a/InvenTree/plugin/models.py +++ b/InvenTree/plugin/models.py @@ -113,6 +113,12 @@ class PluginSetting(common.models.BaseInvenTreeSetting): ('plugin', 'key'), ] + def clean(self, **kwargs): + + kwargs['plugin'] = self.plugin + + super().clean(**kwargs) + """ We override the following class methods, so that we can pass the plugin instance diff --git a/InvenTree/templates/InvenTree/settings/setting.html b/InvenTree/templates/InvenTree/settings/setting.html index 91d03849ce..16fc67ef86 100644 --- a/InvenTree/templates/InvenTree/settings/setting.html +++ b/InvenTree/templates/InvenTree/settings/setting.html @@ -38,7 +38,7 @@
-
diff --git a/InvenTree/templates/InvenTree/settings/settings.html b/InvenTree/templates/InvenTree/settings/settings.html index cb87c6765b..9b3d2d21de 100644 --- a/InvenTree/templates/InvenTree/settings/settings.html +++ b/InvenTree/templates/InvenTree/settings/settings.html @@ -62,16 +62,27 @@ $('table').find('.btn-edit-setting').click(function() { var setting = $(this).attr('setting'); var pk = $(this).attr('pk'); - + var plugin = $(this).attr('plugin'); var is_global = true; if ($(this).attr('user')){ is_global = false; } + var title = ''; + + if (plugin != null) { + title = '{% trans "Edit Plugin Setting" %}'; + } else if (is_global) { + title = '{% trans "Edit Global Setting" %}'; + } else { + title = '{% trans "Edit User Setting" %}'; + } + editSetting(pk, { + plugin: plugin, global: is_global, - title: is_global ? '{% trans "Edit Global Setting" %}' : '{% trans "Edit User Setting" %}', + title: title, }); });