backendpoint for planing a new meal. Not particularily tested with a proper POST form though so use with care.
This commit is contained in:
@@ -163,6 +163,22 @@ def removeme():
|
|||||||
r = db_engine.execute(text(query), user_id=current_user.user_id, meal_id = meal_id)
|
r = db_engine.execute(text(query), user_id=current_user.user_id, meal_id = meal_id)
|
||||||
return render_template('appresponse.html', message='You were removed from that meal')
|
return render_template('appresponse.html', message='You were removed from that meal')
|
||||||
|
|
||||||
|
@app.route("/planmeal", methods=['POST'])
|
||||||
|
@login_required
|
||||||
|
def plan_meal():
|
||||||
|
if request.form['kuk'] == None:
|
||||||
|
return render_template('appresponse.html', message='Invalid request. Nothing to do here')
|
||||||
|
query = "insert into meals(kuk, eaters, flavor_text, meal_date, selection_deadline, status) values(:kuk, ':eaters', ':flavour_text', ':meal_date', ':selection_deadline', 0);"
|
||||||
|
# correct formating example:
|
||||||
|
# insert into meals(kuk, eaters, flavor_text, meal_date, selection_deadline, status) values(2, '{1,3,4}', 'yum', '2018-12-25 18:22:12', '2018-12-25 10:22:12', 0);
|
||||||
|
r = db_engine.execute(text(query),
|
||||||
|
kuk=request.form['kuk'],
|
||||||
|
eaters=request.form['eaters'],
|
||||||
|
flavour_text=request.form['flavour_text'],
|
||||||
|
meal_date=request.form['meal_date'],
|
||||||
|
selection_deadline=request.form['selection_deadline']
|
||||||
|
)
|
||||||
|
return render_template('appresponse.html', message='The meal is planned')
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
|
|||||||
Reference in New Issue
Block a user