feat: added games list

This commit is contained in:
iritmaximus
2023-02-20 22:18:48 +02:00
parent a9da631af2
commit 35d73bb98e
3 changed files with 36 additions and 1 deletions
+8
View File
@@ -0,0 +1,8 @@
from flaskr.database import db
def query_games():
sql = "SELECT name FROM games"
result = db.session.execute(sql).fetchall()
print(result)
return result
+23
View File
@@ -1 +1,24 @@
<h1>Games</h1>
<style>
table, tr, td {
border: 1px solid black;
border-collapse: collapse;
padding: 5px;
}
</style>
<table>
{% if games_exist %}
<tr>
<td>Name</td>
</tr>
{% for item in games %}
<tr>
<td>{{item[0]}}</td>
</tr>
{% endfor %}
{% endif %}
</table>
<a href="/">Go back</a>
+5 -1
View File
@@ -9,6 +9,7 @@ from flaskr.user import (
create_new_user,
)
from flaskr.times import query_times, add_time
from flaskr.games import query_games
@app.route("/")
@@ -21,7 +22,10 @@ def navigate():
# TODO show 3 games with most times submitted
@app.route("/games")
def get_games():
return render_template("games.html")
games = query_games()
if games is None:
return render_template("games.html", games_exist=False)
return render_template("games.html", games=games, games_exist=True)
# TODO show 3 courses with most activity