Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add manual standings rebuild support

  • Loading branch information...
commit 150766a1af83203834178ed99a681d68472cda75 1 parent ed9f202
@artnez authored
View
2  src/faceoff/models/match.py
@@ -117,7 +117,7 @@ def rebuild_rankings(db, league_id):
# sort the players based on their ranking
rankings = [p for p in players.values()]
- rankings.sort(key=lambda p: p['rating'].mu-3*p['rating'].sigma)
+ rankings.sort(key=lambda p: p['rating'].exposure)
rankings.reverse()
# create rankings
View
4 src/faceoff/static/css/faceoff.css
@@ -20,3 +20,7 @@ form .control-group .control-label span.description a {
font-weight: bold;
text-decoration: none;
}
+
+form.form-horizontal .form-buttons {
+ padding-left: 160px;
+}
View
7 src/faceoff/templates/forms/rebuild.html
@@ -0,0 +1,7 @@
+{% from 'macros/form.html' import render_field, render_radio_field %}
+<form id='rebuild' class='form-horizontal' action='{{ url_for('rebuild') }}' method='post'>
+ <fieldset align='center'>
+ <button type='submit' class='btn btn-large'>Rebuild Standings</button>
+ </fieldset>
+</form>
+
View
6 src/faceoff/templates/forms/settings.html
@@ -1,8 +1,10 @@
{% from 'macros/form.html' import render_field, render_radio_field %}
-<form id='settings' action='{{ request.url }}' method='post'>
+<form id='settings' class='form-horizontal' action='{{ request.url }}' method='post'>
<fieldset>
{{ render_field(settings_form.name, errpos='inline') }}
{{ render_radio_field(settings_form.active) }}
- <button type='submit' class='btn btn-large'>Save</button>
+ <div class='form-buttons'>
+ <button type='submit' class='btn'>Save Settings</button>
+ </div>
</fieldset>
</form>
View
12 src/faceoff/templates/layouts/league.html
@@ -39,6 +39,18 @@
</ul>
</div>
{% endif %}
+ {% with messages = get_flashed_messages() %}
+ {% if messages %}
+ <div id='flash-messages'>
+ {% for message in messages %}
+ <div class='alert alert-success'>
+ <a class="close" data-dismiss="alert" href="#">×</a>
+ {{ message }}
+ </div>
+ {% endfor %}
+ </div>
+ {% endif %}
+ {% endwith %}
<div id='content'>
{% if not current_league.active %}
<div class='alert alert-block'>
View
10 src/faceoff/templates/settings.html
@@ -5,4 +5,14 @@
<h2 class='center'><span>League Settings</span></h2>
{% include 'forms/settings.html' %}
</div>
+<div class='section'>
+ <h2 class='center'><span>Rebuild Standings</span></h2>
+ <div class='alert'>
+ <strong>Warning:</strong> While rebuilding the standings won't break
+ anything, you shouldn't do it unless you have a good reason. Standings
+ are automatically updated whenever a match is reported, so this should
+ only be used when testing something.
+ </div>
+ {% include 'forms/rebuild.html' %}
+</div>
{% endblock %}
View
12 src/faceoff/views.py
@@ -20,7 +20,8 @@
find_league, get_active_leagues, get_inactive_leagues, create_league, \
update_league
from faceoff.models.match import \
- create_match, get_match_history, get_league_ranking, get_user_standing
+ create_match, get_match_history, get_league_ranking, get_user_standing, \
+ rebuild_rankings
from faceoff.models.setting import get_setting
@app.teardown_request
@@ -212,5 +213,14 @@ def settings():
name = form.name.data,
active = True if form.active.data == '1' else False
)
+ flash('League settings updated')
return redirect(url_for('settings', league=league['slug']))
return dict(settings_form=form)
+
+@app.route('/<league>/rebuild/', methods=('POST',))
+@templated()
+@authenticated
+def rebuild():
+ flash('Standings rebuild complete')
+ rebuild_rankings(g.current_league['id'])
+ return redirect(url_for('settings'))
Please sign in to comment.
Something went wrong with that request. Please try again.