Permalink
Browse files

Calling the correct method for station scores.

  • Loading branch information...
1 parent 50b46e6 commit 36268eb149af9b0bc5759f8a6bb1c3658c507947 @exhuma committed Apr 8, 2013
Showing with 22 additions and 6 deletions.
  1. +1 −1 js/app.js
  2. +17 −1 lost_tracker/main.py
  3. +2 −2 lost_tracker/static/js/lost_tracker.js
  4. +2 −2 lost_tracker/templates/station.html
View
@@ -55,7 +55,7 @@ lost_tracker.app.attachEvents = function(stationId) {
var formData = goog.dom.forms.getFormDataMap(evt.target.form);
var formString = goog.dom.forms.getFormDataString(evt.target.form);
goog.net.XhrIo.send(
- '/form_score',
+ '/station_score',
function(evt){
var xhr = evt.target;
var data = xhr.getResponseJson();
View
@@ -8,7 +8,8 @@
url_for, redirect)
from lost_tracker.models import (get_state, advance as db_advance,
- get_form_score_full, set_form_score)
+ get_form_score_full, set_form_score,
+ set_station_score as save_station_score)
from lost_tracker.database import Base
from sqlalchemy.exc import IntegrityError
@@ -138,6 +139,21 @@ def init_form_score():
groups=grps)
+@app.route('/station_score', methods=['POST'])
+def set_station_score():
+ group_id = request.form['group_id']
+ station_id = request.form['station_id']
+ score = request.form['score']
+
+ if group_id:
+ save_station_score(group_id, station_id, score)
+
+ if request.is_xhr:
+ return jsonify(status='ok')
+
+ return redirect(url_for("/")) # TODO: redirect to station page
+
+
@app.route('/form_score', methods=['POST'])
def form_score():
group_id = request.form['group_id']

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -19,8 +19,8 @@
{{row.group.name}}
</div>
<div>
- <form action="{{url_for('index')}}" method="POST">
- <p style="display: none;"><input type="hidden" name="form_id"
+ <form action="{{url_for('set_station_score')}}" method="POST">
+ <p style="display: none;"><input type="hidden" name="station_id"
value="{{station.id}}" /></p>
<p style="display: none;"><input type="hidden" name="group_id"
value="{{row.group.id}}" /></p>

0 comments on commit 36268eb

Please sign in to comment.