diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index 5b01a43ac9..e6c9923c88 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -69,7 +69,7 @@ class BaseInvenTreeSetting(models.Model): super().save() @classmethod - def allValues(cls, user=None): + def allValues(cls, user=None, exclude_hidden=False): """ Return a dict of "all" defined global settings. @@ -94,9 +94,15 @@ class BaseInvenTreeSetting(models.Model): for key in cls.GLOBAL_SETTINGS.keys(): if key.upper() not in settings: - settings[key.upper()] = cls.get_setting_default(key) + if exclude_hidden: + hidden = cls.GLOBAL_SETTINGS[key].get('hidden', False) + + if hidden: + # Remove hidden items + del settings[key.upper()] + for key, value in settings.items(): validator = cls.get_setting_validator(key) diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index 590ea20a6f..a8b21827c4 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -251,6 +251,15 @@ def global_settings(*args, **kwargs): return InvenTreeSetting.allValues() +@register.simple_tag() +def visible_global_settings(*args, **kwargs): + """ + Return any global settings which are not marked as 'hidden' + """ + + return InvenTreeSetting.allValues(exclude_hidden=True) + + @register.simple_tag() def progress_bar(val, max, *args, **kwargs): """ diff --git a/InvenTree/templates/js/dynamic/settings.js b/InvenTree/templates/js/dynamic/settings.js index 8201dc8374..e19bba6501 100644 --- a/InvenTree/templates/js/dynamic/settings.js +++ b/InvenTree/templates/js/dynamic/settings.js @@ -13,7 +13,7 @@ const user_settings = { {% endfor %} }; -{% global_settings as GLOBAL_SETTINGS %} +{% visible_global_settings as GLOBAL_SETTINGS %} const global_settings = { {% for key, value in GLOBAL_SETTINGS.items %} {{ key }}: {% primitive_to_javascript value %},