get user settings in templates

This commit is contained in:
Matthias 2021-07-23 00:46:48 +02:00
parent 50356afd41
commit e167f27258
2 changed files with 4 additions and 2 deletions

View File

@ -194,7 +194,7 @@ class BaseInvenTreeSetting(models.Model):
return None
@classmethod
def get_setting(cls, key, backup_value=None):
def get_setting(cls, key, backup_value=None, **kwargs):
"""
Get the value of a particular setting.
If it does not exist, return the backup value (default = None)
@ -204,7 +204,7 @@ class BaseInvenTreeSetting(models.Model):
if backup_value is None:
backup_value = cls.get_setting_default(key)
setting = cls.get_setting_object(key)
setting = cls.get_setting_object(key, **kwargs)
if setting:
value = setting.value

View File

@ -196,6 +196,8 @@ def settings_value(key, *args, **kwargs):
Return a settings value specified by the given key
"""
if 'user' in kwargs:
return InvenTreeUserSetting.get_setting(key, user=kwargs['user'])
return InvenTreeSetting.get_setting(key)