Update app.py

parent 06eb629a
Pipeline #2894 failed with stages
in 10 seconds
......@@ -36,7 +36,9 @@ def handle_register():
elif request.method == "POST":
osm_display_name = request.form.get('username')
user_email = request.form.get('email')
college = request.form.get('colege')
id = request.form.get('id')
dist = request.form.get['dist']
if (osm_display_name and user_email) is not None:
db_connection = sqlite3.connect('data.sqlite3')
db_cursor = db_connection.cursor()
......@@ -52,8 +54,8 @@ def handle_register():
# if the query result is None, then add user
try:
if row_set is None:
insert_query = "insert into leaderboard (display_name, user_email, last_update) values ('{}', '{}', '{}')"
db_cursor.execute(insert_query.format(osm_display_name, user_email, EVENT_DATE))
insert_query = "insert into leaderboard (display_name, user_email, last_update, college, id, dist) values ('{}', '{}', '{}', '{}', '{}')"
db_cursor.execute(insert_query.format(osm_display_name, user_email, EVENT_DATE, college, id, dist))
db_connection.commit()
message = "Registered. Thanks."
except sqlite3.IntegrityError as ie:
......@@ -71,7 +73,7 @@ def handle_register():
def handle_leaderboard():
db_connection = sqlite3.connect('data.sqlite3')
db_cursor = db_connection.cursor()
db_cursor.execute("select display_name, current_score, last_update from leaderboard order by -current_score;")
db_cursor.execute("select display_name, current_score, college from leaderboard order by -current_score;")
result_set = db_cursor.fetchall()
db_connection.close()
return render_template('leaderboard.html', result_set=result_set)
......
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