Added new option to the web theme app, 'WEB_THEME_VERBOSE_LOGIN' that display a more information on the login screen (version, copyright, logos)
This commit is contained in:
@@ -9,5 +9,6 @@ register_settings(
|
||||
settings=[
|
||||
{'name': u'THEME', 'global_name': u'WEB_THEME_THEME', 'default': u'default', 'description': _(u'CSS theme to apply, options are: amro, bec, bec-green, blue, default, djime-cerulean, drastic-dark, kathleene, olive, orange, red, reidb-greenish and warehouse.')},
|
||||
{'name': u'ENABLE_SCROLL_JS', 'global_name': u'WEB_THEME_ENABLE_SCROLL_JS', 'default': True, 'hidden': True},
|
||||
{'name': u'VERBOSE_LOGIN', 'global_name': u'WEB_THEME_VERBOSE_LOGIN', 'default': True, 'description': _(u'Display extra information in the login screen.')},
|
||||
]
|
||||
)
|
||||
|
||||
@@ -45,5 +45,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% get_web_theme_setting "VERBOSE_LOGIN" as verbose_login %}
|
||||
{% if verbose_login %}
|
||||
{% include "verbose_login.html" %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% endif %}
|
||||
|
||||
@@ -47,3 +47,30 @@ class LoginRedirectNode(Node):
|
||||
@register.tag
|
||||
def get_login_redirect_url(parser, token):
|
||||
return LoginRedirectNode()
|
||||
|
||||
|
||||
class SettingsNode(Node):
|
||||
def __init__(self, format_string, var_name):
|
||||
self.format_string = format_string
|
||||
self.var_name = var_name
|
||||
|
||||
def render(self, context):
|
||||
context[self.var_name] = getattr(web_theme_settings, self.format_string, '')
|
||||
return ''
|
||||
|
||||
|
||||
@register.tag
|
||||
def get_web_theme_setting(parser, token):
|
||||
# This version uses a regular expression to parse tag contents.
|
||||
try:
|
||||
# Splitting by None == splitting by spaces.
|
||||
tag_name, arg = token.contents.split(None, 1)
|
||||
except ValueError:
|
||||
raise TemplateSyntaxError('%r tag requires arguments' % token.contents.split()[0])
|
||||
m = re.search(r'(.*?) as (\w+)', arg)
|
||||
if not m:
|
||||
raise TemplateSyntaxError('%r tag had invalid arguments' % tag_name)
|
||||
format_string, var_name = m.groups()
|
||||
if not (format_string[0] == format_string[-1] and format_string[0] in ('"', "'")):
|
||||
raise TemplateSyntaxError('%r tag\'s argument should be in quotes' % tag_name)
|
||||
return SettingsNode(format_string[1:-1], var_name)
|
||||
|
||||
Reference in New Issue
Block a user