From 3f6c7df7a8e6aa3635df6c053634ad676618270a Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 22 Jul 2021 23:48:28 +0200 Subject: [PATCH] change template setting behaviour for user setting --- InvenTree/part/templatetags/inventree_extras.py | 9 +++++---- InvenTree/templates/InvenTree/settings/setting.html | 9 +++++++-- InvenTree/templates/InvenTree/settings/settings.html | 7 ++++++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index 38689df26b..8c28d997f6 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -18,7 +18,7 @@ from InvenTree import version, settings import InvenTree.helpers -from common.models import InvenTreeSetting, ColorTheme +from common.models import InvenTreeSetting, ColorTheme, InvenTreeUserSetting from common.settings import currency_code_default register = template.Library() @@ -182,11 +182,12 @@ def setting_object(key, *args, **kwargs): """ Return a setting object speciifed by the given key (Or return None if the setting does not exist) + if a user-setting was requested return that """ - setting = InvenTreeSetting.get_setting_object(key) - - return setting + if 'user' in kwargs: + return InvenTreeUserSetting.get_setting_object(key, user=kwargs['user']) + return InvenTreeSetting.get_setting_object(key) @register.simple_tag() diff --git a/InvenTree/templates/InvenTree/settings/setting.html b/InvenTree/templates/InvenTree/settings/setting.html index 7376adf8d9..66f3f9f3b0 100644 --- a/InvenTree/templates/InvenTree/settings/setting.html +++ b/InvenTree/templates/InvenTree/settings/setting.html @@ -1,7 +1,12 @@ {% load inventree_extras %} {% load i18n %} -{% setting_object key as setting %} +{% if user_setting %} + {% setting_object key user=request.user as setting %} +{% else %} + {% setting_object key as setting %} +{% endif %} + {% if icon %} @@ -28,7 +33,7 @@
-
diff --git a/InvenTree/templates/InvenTree/settings/settings.html b/InvenTree/templates/InvenTree/settings/settings.html index 25ae5d24b2..03cf276594 100644 --- a/InvenTree/templates/InvenTree/settings/settings.html +++ b/InvenTree/templates/InvenTree/settings/settings.html @@ -45,9 +45,14 @@ $('table').find('.btn-edit-setting').click(function() { var setting = $(this).attr('setting'); var pk = $(this).attr('pk'); + var url = `/settings/${pk}/edit/`; + + if ($(this).attr('user')){ + url += `user/`; + } launchModalForm( - `/settings/${pk}/edit/`, + url, { reload: true, }