Commit f63292f2 authored by Willard's avatar Willard

Add review endpoints

parent 48b8c71a
from canteeneo import app, db, auth
from flask import jsonify, request, g
from models import Dish, Stall, Location, User
from models import Dish, Stall, Location, User, DishReview, StallReview
from datetime import datetime
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer, BadSignature, SignatureExpired
......@@ -107,7 +107,14 @@ def favorite_dish(dish_id):
@app.route('/api/dish/<int:dish_id>/review', methods=['POST'])
@auth.login_required
def review_dish(dish_id):
pass
user_id = g.user.id
title = request.form['title']
body = request.form['body']
rating = int(request.form['rating'])
db.session.add(DishReview(title, body, rating, user_id, dish_id))
db.session.commit()
return 'Review posted'
@app.route('/api/stall/<int:stall_id>/favorite', methods=['GET'])
@auth.login_required
......@@ -123,4 +130,10 @@ def favorite_stall(stall_id):
@app.route('/api/stall/<int:stall_id>/review', methods=['POST'])
@auth.login_required
def review_stall(stall_id):
pass
user_id = g.user.id
title = request.form['title']
body = request.form['body']
rating = int(request.form['rating'])
db.session.add(StallReview(title, body, rating, user_id, stall_id))
db.session.commit()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment