mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add "hidden" property to global settings
- Allows certain settings to be hidden from the javascript files
This commit is contained in:
parent
2f3772f3bf
commit
626637a06a
@ -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)
|
||||
|
||||
|
@ -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):
|
||||
"""
|
||||
|
@ -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 %},
|
||||
|
Loading…
Reference in New Issue
Block a user