From 038452f9a61f74c9401118d30d7c477af7fd80c6 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 4 Sep 2022 00:32:46 +0200 Subject: [PATCH] display total hat sales in /hats --- files/routes/hats.py | 3 ++- files/templates/hats.html | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/files/routes/hats.py b/files/routes/hats.py index e2d28947c..e04b34147 100644 --- a/files/routes/hats.py +++ b/files/routes/hats.py @@ -21,7 +21,8 @@ def hats(v): not_owned = g.db.query(HatDef, User).join(HatDef.author).filter(HatDef.id.notin_(owned_hat_ids)).order_by(HatDef.price, HatDef.name).all() hats = owned + not_owned - return render_template("hats.html", owned_hat_ids=owned_hat_ids, hats=hats, v=v) + sales = g.db.query(func.sum(User.coins_spent_on_hats)).scalar() + return render_template("hats.html", owned_hat_ids=owned_hat_ids, hats=hats, v=v, sales=sales) @app.post("/buy_hat/") @auth_required diff --git a/files/templates/hats.html b/files/templates/hats.html index d24f817bf..3de590d77 100644 --- a/files/templates/hats.html +++ b/files/templates/hats.html @@ -12,6 +12,7 @@
Number of hats you bought: {{v.num_of_owned_hats}}
Number of hats you designed: {{v.num_of_designed_hats}}
Coins you spent on hats: {{v.coins_spent_on_hats}}
+
Total hat sales: {{sales}}
{% endblock %}