Merge branch 'master' of git.elab.kth.se:davide/KUKapp
This commit is contained in:
@@ -148,8 +148,9 @@ def addme():
|
|||||||
results = []
|
results = []
|
||||||
for row in r:
|
for row in r:
|
||||||
results.append(dict(row))
|
results.append(dict(row))
|
||||||
|
if not results[0]['is_eater'] == 'True':
|
||||||
if not results[0]['is_eater']:
|
query = "UPDATE meals SET eaters = array_cat(eaters, '{:user_id}') where 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='Have a nice meal ' + meal_id + " mister " + str(current_user.name) )
|
return render_template('appresponse.html', message='Have a nice meal ' + meal_id + " mister " + str(current_user.name) )
|
||||||
else:
|
else:
|
||||||
return render_template('appresponse.html', message='You are already a registered eater')
|
return render_template('appresponse.html', message='You are already a registered eater')
|
||||||
@@ -162,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