From 2ac21bd03266bf8d4dc2db91420639d0374e57fe Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sat, 2 Jul 2011 03:31:32 -0400 Subject: [PATCH] Added new option to the web theme app, 'WEB_THEME_VERBOSE_LOGIN' that display a more information on the login screen (version, copyright, logos) --- apps/main/templates/about.html | 24 +++-------------- apps/main/templates/project_description.html | 23 ++++++++++++++++ apps/main/templates/verbose_login.html | 9 +++++++ apps/web_theme/conf/settings.py | 1 + apps/web_theme/templates/web_theme_login.html | 4 +++ apps/web_theme/templatetags/theme_tags.py | 27 +++++++++++++++++++ 6 files changed, 67 insertions(+), 21 deletions(-) create mode 100644 apps/main/templates/project_description.html create mode 100644 apps/main/templates/verbose_login.html diff --git a/apps/main/templates/about.html b/apps/main/templates/about.html index c2b1dc2b0b..69649cf3c4 100644 --- a/apps/main/templates/about.html +++ b/apps/main/templates/about.html @@ -5,29 +5,11 @@ {% block title %} :: {% trans "About this program" %}{% endblock %} {% block content %} -
-

{% project_name %} ({% trans "Version" %} {% app_version "main" %})

-

- {% trans "Open source, Django based electronic document manager with custom metadata, indexing, tagging, file serving integration and OCR capabilities" %} -

-

- http://bit.ly/mayan-edms -

-

- http://www.github.com/rosarior/mayan/ -

-

- {% trans "Released under the GPL V3 License" %} -

-
- -
-
- - +
+

{% project_name %} ({% trans "Version" %} {% app_version "main" %})

+ {% include "project_description.html" %} -
{% endblock %} {% block footer %}
+ {% get_web_theme_setting "VERBOSE_LOGIN" as verbose_login %} + {% if verbose_login %} + {% include "verbose_login.html" %} + {% endif %} {% endblock %} {% endif %} diff --git a/apps/web_theme/templatetags/theme_tags.py b/apps/web_theme/templatetags/theme_tags.py index ae1e3cbe36..f8bbb50b93 100644 --- a/apps/web_theme/templatetags/theme_tags.py +++ b/apps/web_theme/templatetags/theme_tags.py @@ -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)