mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fix rendering issues
This commit is contained in:
parent
27ec65a002
commit
a222efda33
@ -75,6 +75,28 @@ class BaseInvenTreeSetting(models.Model):
|
||||
"value": cls.get_setting_default(key)
|
||||
})
|
||||
|
||||
# Enforce javascript formatting
|
||||
for idx, setting in enumerate(settings):
|
||||
|
||||
key = setting['key']
|
||||
value = setting['value']
|
||||
|
||||
validator = cls.get_setting_validator(key)
|
||||
|
||||
# Convert to javascript compatible booleans
|
||||
if cls.validator_is_bool(validator):
|
||||
value = 'true' if value else 'false'
|
||||
|
||||
# Numerical values remain the same
|
||||
elif cls.validator_is_int(validator):
|
||||
pass
|
||||
|
||||
# Wrap strings with quotes
|
||||
else:
|
||||
value = f"'{value}'"
|
||||
|
||||
setting["value"] = value
|
||||
|
||||
return settings
|
||||
|
||||
@classmethod
|
||||
@ -407,13 +429,7 @@ class BaseInvenTreeSetting(models.Model):
|
||||
|
||||
validator = self.__class__.get_setting_validator(self.key)
|
||||
|
||||
if validator == bool:
|
||||
return True
|
||||
|
||||
if type(validator) in [list, tuple]:
|
||||
for v in validator:
|
||||
if v == bool:
|
||||
return True
|
||||
return self.__class__.validator_is_bool(validator)
|
||||
|
||||
def as_bool(self):
|
||||
"""
|
||||
@ -424,6 +440,19 @@ class BaseInvenTreeSetting(models.Model):
|
||||
|
||||
return InvenTree.helpers.str2bool(self.value)
|
||||
|
||||
@classmethod
|
||||
def validator_is_bool(cls, validator):
|
||||
|
||||
if validator == bool:
|
||||
return True
|
||||
|
||||
if type(validator) in [list, tuple]:
|
||||
for v in validator:
|
||||
if v == bool:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def is_int(self):
|
||||
"""
|
||||
Check if the setting is required to be an integer value:
|
||||
@ -431,6 +460,11 @@ class BaseInvenTreeSetting(models.Model):
|
||||
|
||||
validator = self.__class__.get_setting_validator(self.key)
|
||||
|
||||
return self.__class__.validator_is_int(validator)
|
||||
|
||||
@classmethod
|
||||
def validator_is_int(cls, validator):
|
||||
|
||||
if validator == int:
|
||||
return True
|
||||
|
||||
|
@ -6,12 +6,12 @@
|
||||
|
||||
var user_settings = {
|
||||
{% for setting in USER_SETTINGS %}
|
||||
{{ setting.key }}: {{ setting.value }},
|
||||
{{ setting.key }}: {{ setting.value|safe }},
|
||||
{% endfor %}
|
||||
};
|
||||
|
||||
var global_settings = {
|
||||
{% for setting in GLOBAL_SETTINGS %}
|
||||
{{ setting.key }}: {{ setting.value }},
|
||||
{{ setting.key }}: {{ setting.value|safe }},
|
||||
{% endfor %}
|
||||
};
|
@ -147,6 +147,7 @@ function getAvailableTableFilters(tableKey) {
|
||||
title: '{% trans "Depleted" %}',
|
||||
description: '{% trans "Show stock items which are depleted" %}',
|
||||
},
|
||||
|
||||
{% settings_value "STOCK_ENABLE_EXPIRY" as expiry %}
|
||||
{% if expiry %}
|
||||
expired: {
|
||||
|
Loading…
Reference in New Issue
Block a user