1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00

Added a "Visual enhacements" configuration variable and a template tag (inside html5) to allow switching between enhanced display effects and no effects (it will depend on template)

This commit is contained in:
Adolfo Gómez 2014-06-12 07:27:54 +00:00
parent 0a3433b2f5
commit 75c9313a0f
4 changed files with 42 additions and 6 deletions

View File

@ -258,6 +258,9 @@ class GlobalConfig(object):
# Gui vars
UDS_THEME = Config.section(GLOBAL_SECTION).value('UDS Theme', 'html5')
# This is used so templates can change "styles" from admin interface
UDS_THEME_VISUAL = Config.section(GLOBAL_SECTION).value('UDS Theme Enhaced', '1')
initDone = False
@staticmethod

View File

@ -1,4 +1,4 @@
{% load i18n %}
{% load i18n html5 %}
<div class="row">
<div class="col-xs-12">
<h1>{% trans 'Authenticators' %}</h1>
@ -20,7 +20,7 @@
<li><a href="#{{ logs }}" data-toggle="tab">{% endverbatim %}{% trans 'Logs' %}{% verbatim %}</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane fade in active" id="{{ users }}_tab">
<div class="tab-pane{% endverbatim %}{% enhaced_visual %} fade {% endenhaced_visual%}{% verbatim %}active" id="{{ users }}_tab">
<div class="row">
<div class="col-xs-12" id="{{ users }}">
</div>
@ -30,8 +30,8 @@
</div>
</div>
</div>
<div class="tab-pane fade" id="{{ groups }}"></div>
<div class="tab-pane fade" id="{{ logs }}">...</div>
<div class="tab-pane{% endverbatim %}{% enhaced_visual %} fade{% endenhaced_visual%}{% verbatim %}" id="{{ groups }}"></div>
<div class="tab-pane{% endverbatim %}{% enhaced_visual %} fade{% endenhaced_visual%}{% verbatim %}" id="{{ logs }}">...</div>
</div>
</div>
</div>

View File

@ -1,6 +1,6 @@
{% load i18n %}
{% load i18n html5 %}
{% verbatim %}
<div id="{{ id }}" class="modal fade">
<div id="{{ id }}" class="modal{% endverbatim %}{% enhaced_visual %} fade{% endenhaced_visual%}{% verbatim %}" data-backdrop="static">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">

View File

@ -34,6 +34,7 @@ from __future__ import unicode_literals
from django import template
from uds.core.util import html
from uds.core.util.Config import GlobalConfig
import logging
@ -52,6 +53,38 @@ def country(lang):
return lang.upper()
# Config related
@register.assignment_tag
def get_theme():
return GlobalConfig.UDS_THEME.get()
class EnhacedVisual(template.Node):
def __init__(self, nodelistTrue, nodelistFalse):
self._nodelistTrue = nodelistTrue
self._nodelistFalse = nodelistFalse
def render(self, context):
if GlobalConfig.UDS_THEME_VISUAL.getBool() is True:
return self._nodelistTrue.render(context)
if self._nodelistFalse is None:
return ''
return self._nodelistFalse.render(context)
@register.tag(name='enhaced_visual')
def enhaced_visual(parser, token):
states = {}
default_states = ['enhaced_visual', 'else']
end_tag = 'endenhaced_visual'
while token.contents != end_tag:
current = token.contents
states[current.split()[0]] = parser.parse(default_states + [end_tag])
token = parser.next_token()
return EnhacedVisual(states['enhaced_visual'], states.get('else', None))
# Browser related
class IfBrowser(template.Node):