Skip to content

Commit

Permalink
[#2302] set style via form
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Jul 25, 2012
1 parent 032b9ac commit 16cb7a3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
11 changes: 11 additions & 0 deletions ckan/controllers/admin.py
Expand Up @@ -28,6 +28,17 @@ def __before__(self, action, **params):
model.Action.CHANGE_STATE,
model.Revision))

def config(self):
app_globals = base.pylons_globals().get('g')
style = request.POST.get('style')
if style:
style ='/base/css/%s.css' % style
app_globals._set_main_css(style)
styles = ['main', 'red', 'green', 'fuchsia']

return base.render('admin/config.html',
extra_vars = {'styles': styles })

def index(self):
#now pass the list of sysadmins
c.sysadmins = [a.name for a in get_sysadmins()]
Expand Down
2 changes: 1 addition & 1 deletion ckan/lib/app_globals.py
Expand Up @@ -19,7 +19,7 @@ def _set_main_css(self, css_file):
else:
new_css = css_file
# FIXME we should check the css file exists
self.main_css = new_css
self.main_css = str(new_css)
print 'using css file %s' % self.main_css

def __init__(self):
Expand Down
24 changes: 24 additions & 0 deletions ckan/templates/admin/config.html
@@ -0,0 +1,24 @@
{% extends "page.html" %}

{% block title %}{{ _('Administration') }} - {{ super() }}{% endblock %}

{% block breadcrumb_content %}
{% endblock %}

{% block primary %}
<article class="module">
<div class="module-content">
<h1 class="page-heading">{{ _('Configuration Settings') }}</h1>
<form method='post' action="">
<select name="style">
{% for style in styles|sort %}
<option value="{{ style }}" >{{ style }}</option>
{% endfor %}
</select>
<button type="submit" >Update</button>
</form>
</div>
</article>
{% endblock %}

{% block sidebar %}{% endblock %}

0 comments on commit 16cb7a3

Please sign in to comment.