Conver web app theme to new settings app

This commit is contained in:
Roberto Rosario
2012-09-05 14:07:06 -04:00
parent 7180245f8c
commit 773442425e
3 changed files with 40 additions and 4 deletions

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,30 @@
"""
Configuration options for the web_theme app
"""
from django.utils.translation import ugettext_lazy as _
from smart_settings import SettingsNamespace, LocalScope
namespace = SettingsNamespace(name='web_theme', label=_(u'Web theme'), module='web_theme.settings')
namespace.add_setting(
name='THEME',
default=u'activo',
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.'),
scopes=[LocalScope()]
)
namespace.add_setting(
name='ENABLE_SCROLL_JS',
default=True,
hidden=True,
scopes=[LocalScope()]
)
namespace.add_setting(
name='VERBOSE_LOGIN',
default=True,
description=_(u'Display extra information in the login screen.'),
scopes=[LocalScope()]
)

View File

@@ -4,7 +4,7 @@ from django.conf import settings
from django.template import Library, Node, TemplateSyntaxError
from django.utils.safestring import mark_safe
from web_theme.conf import settings as web_theme_settings
from web_theme.settings import THEME, ENABLE_SCROLL_JS
register = Library()
@@ -14,8 +14,8 @@ class GetThemeNode(Node):
self.var_name = var_name
def render(self, context):
context['web_theme'] = web_theme_settings.THEME
context['enable_scroll_js'] = web_theme_settings.ENABLE_SCROLL_JS
context['web_theme'] = THEME
context['enable_scroll_js'] = ENABLE_SCROLL_JS
return ''
@@ -56,7 +56,12 @@ class SettingsNode(Node):
self.var_name = var_name
def render(self, context):
context[self.var_name] = getattr(web_theme_settings, self.format_string, '')
#TODO: fix properly
if self.format_string == 'THEME':
context[self.var_name] = THEME
else:
context[self.var_name] = ENABLE_SCROLL_JS
#context[self.var_name] = getattr(web_theme_settings, self.format_string, '')
return ''