mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Partial reversion of some stuff
This commit is contained in:
parent
faab1f2464
commit
cef09acd54
@ -72,26 +72,6 @@ def status_codes(request):
|
||||
}
|
||||
|
||||
|
||||
def inventree_settings(request):
|
||||
"""
|
||||
Adds two context objects to the request:
|
||||
|
||||
user_settings - A key:value dict of all user InvenTree settings for the current user
|
||||
global_settings - A key:value dict of all global InvenTree settings
|
||||
|
||||
Providing a single context object for all settings should reduce the number of db hits
|
||||
"""
|
||||
|
||||
ctx = {}
|
||||
|
||||
if request.user:
|
||||
ctx["user_settings"] = common.models.InvenTreeUserSetting.allValues(user=request.user)
|
||||
|
||||
ctx["global_settings"] = common.models.InvenTreeSetting.allValues()
|
||||
|
||||
return ctx
|
||||
|
||||
|
||||
def user_roles(request):
|
||||
"""
|
||||
Return a map of the current roles assigned to the user.
|
||||
|
@ -324,7 +324,6 @@ TEMPLATES = [
|
||||
'InvenTree.context.health_status',
|
||||
'InvenTree.context.status_codes',
|
||||
'InvenTree.context.user_roles',
|
||||
'InvenTree.context.inventree_settings',
|
||||
],
|
||||
},
|
||||
},
|
||||
|
@ -209,6 +209,24 @@ def settings_value(key, *args, **kwargs):
|
||||
return InvenTreeSetting.get_setting(key)
|
||||
|
||||
|
||||
@register.simple_tag()
|
||||
def user_settings(user, *args, **kwargs):
|
||||
"""
|
||||
Return all USER settings as a key:value dict
|
||||
"""
|
||||
|
||||
return InvenTreeUserSetting.allValues(user=user)
|
||||
|
||||
|
||||
@register.simple_tag()
|
||||
def global_settings(*args, **kwargs):
|
||||
"""
|
||||
Return all GLOBAL InvenTree settings as a key:value dict
|
||||
"""
|
||||
|
||||
return InvenTreeSetting.allValues()
|
||||
|
||||
|
||||
@register.simple_tag()
|
||||
def get_color_theme_css(username):
|
||||
try:
|
||||
|
@ -1,14 +1,18 @@
|
||||
{% load inventree_extras %}
|
||||
// InvenTree settings
|
||||
|
||||
{% user_settings request.user as USER_SETTINGS %}
|
||||
|
||||
var user_settings = {
|
||||
{% for key, value in user_settings.items %}
|
||||
{% for key, value in USER_SETTINGS.items %}
|
||||
{{ key }}: {% primitive_to_javascript value %},
|
||||
{% endfor %}
|
||||
};
|
||||
|
||||
{% global_settings as GLOBAL_SETTINGS %}
|
||||
|
||||
var global_settings = {
|
||||
{% for key, value in global_settings.items %}
|
||||
{% for key, value in GLOBAL_SETTINGS.items %}
|
||||
{{ key }}: {% primitive_to_javascript value %},
|
||||
{% endfor %}
|
||||
};
|
Loading…
Reference in New Issue
Block a user