|
|
|
@ -24,7 +24,8 @@ users = {}
|
|
|
|
|
class User(UserMixin):
|
|
|
|
|
def __init__(self, name):
|
|
|
|
|
self.name = name
|
|
|
|
|
self.id = -1
|
|
|
|
|
self.id = name
|
|
|
|
|
self.user_id = -1
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def get(name):
|
|
|
|
@ -73,6 +74,7 @@ def getUpcomingMeals():
|
|
|
|
|
meals[-1]['selection_deadline'] = str(round(seconds_to_deadline / 60)) + ' minutes'
|
|
|
|
|
meals[-1]['meal_time'] = meals[-1]['meal_date'].strftime('%H:%M')
|
|
|
|
|
meals[-1]['meal_date'] = meals[-1]['meal_date'].strftime('%A %d %B')
|
|
|
|
|
meals[-1]['candidate'] = 'davide'
|
|
|
|
|
r.close()
|
|
|
|
|
return meals
|
|
|
|
|
|
|
|
|
@ -82,7 +84,7 @@ def getUpcomingMeals():
|
|
|
|
|
def addme():
|
|
|
|
|
meal_id = request.args.get('meal')
|
|
|
|
|
query = 'select :user_id = any (eaters) from meals where id =:meal_id;'
|
|
|
|
|
r = db_engine.execute(text(query), user_id=current_user.id, meal_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))
|
|
|
|
@ -93,8 +95,9 @@ def addme():
|
|
|
|
|
return render_template('appresponse.html', message='Only one meal per person!')
|
|
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
|
@login_required
|
|
|
|
|
def index():
|
|
|
|
|
return render_template('meal_list.html', leaderboard=getLeaderboard(), meals=getUpcomingMeals(), current_user_name='Wille')
|
|
|
|
|
return render_template('meal_list.html', leaderboard=getLeaderboard(), meals=getUpcomingMeals())
|
|
|
|
|
|
|
|
|
|
@app.route('/login', methods=['GET', 'POST'])
|
|
|
|
|
def login():
|
|
|
|
@ -109,7 +112,7 @@ def login():
|
|
|
|
|
print(len(users))
|
|
|
|
|
if len(result) > 0:
|
|
|
|
|
u = User.get(username)
|
|
|
|
|
u.id = result[0]['id']
|
|
|
|
|
u.user_id = result[0]['id']
|
|
|
|
|
login_user(u)
|
|
|
|
|
return redirect(request.args.get("next"))
|
|
|
|
|
return abort(401)
|
|
|
|
|