Beispiel #1
0
    RouteHelper.join(route_id)
    return redirect(url_for('route.route_page', route_id=route_id))


@route_blueprint.route('/finish_attach/<route_id>/<attachment_id>/', methods=['GET'])
@login_required
def finish_attach(route_id, attachment_id):
    try:
        route_id = ObjectId(route_id)
        attachment_id = ObjectId(attachment_id)
        assert RouteHelper.get(route_id)
        assert AttachmentHelper.get(attachment_id)
    except AssertionError, e:
        return redirect(url_for('home.home'))

    RouteHelper.finish_attach(route_id, attachment_id)
    return redirect(url_for('route.route_page', route_id=route_id))


@route_blueprint.route('/route/<route_id>/rate/', methods=['POST'])
@login_required
def rate(route_id):
    try:
        route_id = ObjectId(route_id)
        assert 'score' in request.form
        score = int(request.form['score'])
        assert RouteHelper.get(route_id)
    except AssertionError, e:
        return redirect(url_for('home.home'))

    RouteHelper.rate(route_id, score)