def __init__(self, stations, groups): self._stations = stations self._groups = groups self._matrix = [] for group in groups: tmp = [group] for station in stations: tmp.append(GroupStation.get(group.id, station.id)) self._matrix.append(tmp)
def score(group_id): station_id = int(request.form['station_id']) try: station_score = int(request.form['station_score']) except ValueError as exc: app.logger.exception(exc) station_score = None try: form_id = int(request.form['form_id']) form_score = int(request.form['form_score']) except: form_id = None form_score = 0 if station_score is not None: group_station = GroupStation.get( group_id, station_id) if not group_station: group_station = GroupStation( group_id, station_id) g.session.add(group_station) group_station.score = int(station_score) if form_id is not None: set_form_score(group_id, form_id, int(form_score)) if request.is_xhr: return jsonify( station_score=station_score, form_score=form_score, status='ok') return redirect(url_for("/")) # TODO: redirect to station page