|
|
|
@ -87,20 +87,20 @@ def getUpcomingMeals():
|
|
|
|
|
@login_required
|
|
|
|
|
def addme():
|
|
|
|
|
meal_id = request.args.get('meal')
|
|
|
|
|
query = 'select :user_id = any (eaters) from meals where id =:meal_id;'
|
|
|
|
|
query = 'select :user_id = any (eaters) as is_eater from meals where id =:meal_id;'
|
|
|
|
|
r = db_engine.execute(text(query), user_id=current_user.user_id, meal_id = meal_id)
|
|
|
|
|
results = []
|
|
|
|
|
for row in r:
|
|
|
|
|
results.append(dict(row))
|
|
|
|
|
|
|
|
|
|
if 1==1:
|
|
|
|
|
|
|
|
|
|
if not results['is_eater']:
|
|
|
|
|
return render_template('appresponse.html', message='Have a nice meal ' + meal_id + " mister " + str(current_user.name) )
|
|
|
|
|
else:
|
|
|
|
|
return render_template('appresponse.html', message='Only one meal per person!')
|
|
|
|
|
return render_template('appresponse.html', message='You are already a registered eater')
|
|
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
|
def index():
|
|
|
|
|
return render_template('meal_list.html', leaderboard=getLeaderboard(), meals=getUpcomingMeals())
|
|
|
|
|
return render_template('meal_list.html', leaderboard=getLeaderboard(), meals=getUpcomingMeals(), now=datetime.datetime.now())
|
|
|
|
|
|
|
|
|
|
@app.route('/login', methods=['GET', 'POST'])
|
|
|
|
|
def login():
|
|
|
|
|