Permalink
Browse files

repurpose the admin screen

  • Loading branch information...
1 parent 49c355b commit 50d2f74d41ecb235de15de4a8a0fb657652bf7c5 @artnez committed May 22, 2012
@@ -98,7 +98,7 @@ class ProfileForm(Form):
validators=[Optional(), Length(4)]
)
-class ConfigForm(Form):
+class AdminForm(Form):
access_code = TextField(
label='Access Code',
id='access_code',
@@ -24,3 +24,10 @@ def set_setting(db, name, value=None):
@use_db
def del_setting(db, name):
db.execute('DELETE FROM setting WHERE name=?', (name,))
+
+@use_db
+def set_access_code(db, code):
+ if code == '':
+ del_setting(db, 'access_code')
+ else:
+ set_setting(db, 'access_code', code)
@@ -13,25 +13,6 @@ p.search-empty {
font-style: italic;
}
-#content .section {
- margin: 0 0 40px 0;
-}
-
-#content .section h2.center {
- color: #333;
- text-align: center;
- font-family: Georgia;
- font-weight: normal;
- font-style: italic;
- background: url('../img/heading-bg-line.png') no-repeat 0 50%;
- margin: 0 0 20px 0;
-}
-
-#content .section h2.center span {
- background: #fff;
- padding: 0 12px;
-}
-
#report {
background: #eee;
padding: 14px 20px;
@@ -138,6 +138,25 @@ h2 {
display: none;
}
+.section {
+ margin: 0 0 40px 0;
+}
+
+.section h2.center {
+ color: #333;
+ text-align: center;
+ font-family: Georgia;
+ font-weight: normal;
+ font-style: italic;
+ background: url('../img/heading-bg-line.png') no-repeat 0 50%;
+ margin: 0 0 20px 0;
+}
+
+#content .section h2.center span {
+ background: #fff;
+ padding: 0 12px;
+}
+
.league-list h1 {
margin: 0 0 10px 0;
}
@@ -1,8 +1,9 @@
{% extends 'layouts/simple.html' %}
-{% set head_title='League Configuration' %}
+{% set head_title='Administration' %}
{% set logo_url = url_for('landing') %}
{% block content %}
-<div>
- {% include 'forms/config.html' %}
+<div class='section'>
+ <h1>Admin</h1>
+ {% include 'forms/admin.html' %}
</div>
{% endblock %}
@@ -0,0 +1,8 @@
+{% from 'macros/form.html' import render_field %}
+<form id='admin' action='{{ request.url }}' method='post'>
+ <fieldset>
+ {{ render_field(admin_form.access_code, errpos='inline') }}
+ <button type='submit' class='btn btn-large'>Save</button>
+ <a href='#' class='cancel go-back'>cancel</a>
+ </fieldset>
+</form>
@@ -1,8 +0,0 @@
-{% from 'macros/form.html' import render_field %}
-<form id='config' action='{{ request.url }}' method='post'>
- <fieldset>
- {{ render_field(config_form.access_code, errpos='inline') }}
- <button type='submit' class='btn btn-large'>Save Config</button>
- <a href='#' class='cancel go-back'>cancel</a>
- </fieldset>
-</form>
@@ -37,7 +37,7 @@
<ul class='menu'>
<li><span>{{ current_user.nickname }}</span></li>
<li><a href='{{ url_for('profile') }}'>edit profile</a></li>
- <li><a href='{{ url_for('config') }}'>configuration</a></li>
+ <li><a href='{{ url_for('admin') }}'>admin</a></li>
<li><a href='{{ url_for('logout') }}' data-confirm='Are you sure you want to logout?'>logout</a></li>
</ul>
</div>
@@ -14,7 +14,7 @@
<ul class='menu'>
<li><span>{{ current_user.nickname }}</span></li>
<li><a href='{{ url_for('profile') }}'>edit profile</a></li>
- <li><a href='{{ url_for('config') }}'>configuration</a></li>
+ <li><a href='{{ url_for('admin') }}'>admin</a></li>
<li><a href='{{ url_for('logout') }}' data-confirm='Are you sure you want to logout?'>logout</a></li>
</ul>
</div>
View
@@ -13,7 +13,7 @@
from faceoff.debug import debug
from faceoff.forms import \
LoginForm, JoinForm, ReportForm, NewLeagueForm, SettingsForm, ProfileForm, \
- ConfigForm
+ AdminForm
from faceoff.helpers.decorators import authenticated, templated
from faceoff.models.user import \
get_active_users, create_user, update_user, auth_login, auth_logout
@@ -23,7 +23,7 @@
from faceoff.models.match import \
create_match, get_match_history, get_league_ranking, get_user_standing, \
rebuild_rankings
-from faceoff.models.setting import get_setting, del_setting, set_setting
+from faceoff.models.setting import get_setting, set_access_code
@app.teardown_request
def db_close(exception): # pylint:disable=W0613
@@ -157,22 +157,17 @@ def new_league():
create_league(form.name.data)
return redirect(url_for('landing'))
-@app.route('/config', methods=('GET', 'POST'))
+@app.route('/admin', methods=('GET', 'POST'))
@templated()
@authenticated
-def config():
- form = ConfigForm(request.form)
+def admin():
+ form = AdminForm(request.form)
if request.method != 'POST' or not form.validate():
form.access_code.data = get_setting('access_code')
- return dict(config_form=form)
- access_code = form.access_code.data.strip()
- if access_code == '':
- del_setting('access_code')
- flash('Access code removed')
- else:
- set_setting('access_code', access_code)
- flash('Access changed')
- return redirect(url_for('config'))
+ return dict(admin_form=form)
+ set_access_code(form.access_code.data.strip())
+ flash('Settings saved')
+ return redirect(url_for('admin'))
@app.route('/<league>/')
@templated()

0 comments on commit 50d2f74

Please sign in to comment.