From e167f27258a8f4fce34ca74e53809bb431f163da Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 23 Jul 2021 00:46:48 +0200 Subject: [PATCH] get user settings in templates --- InvenTree/common/models.py | 4 ++-- InvenTree/part/templatetags/inventree_extras.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index eebb566a68..48c99cbbb5 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -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 diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index 8c28d997f6..e867441b42 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -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)