mirror of
https://github.com/iritmaximus/timetrials.git
synced 2026-10-12 19:13:48 +03:00
fix: count of cups
This commit is contained in:
@@ -8,6 +8,8 @@ table, tr, td {
|
||||
}
|
||||
</style>
|
||||
|
||||
<p>There is {{count}} cups</p>
|
||||
|
||||
<table>
|
||||
{% if cups_exist %}
|
||||
<tr>
|
||||
|
||||
@@ -4,7 +4,9 @@ from flaskr.database import db
|
||||
def query_cups():
|
||||
sql = "SELECT name, id FROM cups"
|
||||
result = db.session.execute(sql).fetchall()
|
||||
return result
|
||||
sql = "SELECT count(cups.id) FROM cups"
|
||||
count = db.session.execute(sql).fetchone()
|
||||
return result, count[0]
|
||||
|
||||
|
||||
def query_cup_by_name(cup_name: str):
|
||||
|
||||
@@ -10,10 +10,10 @@ from flaskr.utils.cups import (
|
||||
|
||||
@app.route("/cups")
|
||||
def get_cups():
|
||||
cups = query_cups()
|
||||
cups, count = query_cups()
|
||||
if cups is None:
|
||||
return render_template("cups.html", cups_exist=False)
|
||||
return render_template("cups.html", cups=cups, cups_exist=True)
|
||||
return render_template("cups.html", cups_exist=False, count=count)
|
||||
return render_template("cups.html", cups=cups, cups_exist=True, count=count)
|
||||
|
||||
|
||||
@app.route("/cups/<int:cup_id>")
|
||||
|
||||
Reference in New Issue
Block a user