From 49622b3268ebedf5359c273824a29f9d5fb22be0 Mon Sep 17 00:00:00 2001 From: TLSM Date: Tue, 31 May 2022 23:20:39 -0400 Subject: [PATCH] Lottery: add admin participants listing. --- files/helpers/lottery.py | 4 +++- files/routes/lottery.py | 7 +++++++ files/templates/admin/admin_home.html | 7 +++++++ files/templates/admin/lottery.html | 23 +++++++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 files/templates/admin/lottery.html diff --git a/files/helpers/lottery.py b/files/helpers/lottery.py index 619ee6e59e..6949c44926 100644 --- a/files/helpers/lottery.py +++ b/files/helpers/lottery.py @@ -12,7 +12,9 @@ def get_active_lottery(): def get_users_participating_in_lottery(): - return g.db.query(User).filter(User.currently_held_lottery_tickets > 0).all() + return g.db.query(User) \ + .filter(User.currently_held_lottery_tickets > 0) \ + .order_by(User.currently_held_lottery_tickets.desc()).all() def get_active_lottery_stats(): diff --git a/files/routes/lottery.py b/files/routes/lottery.py index ddaa83856b..241f58c238 100644 --- a/files/routes/lottery.py +++ b/files/routes/lottery.py @@ -52,3 +52,10 @@ def lottery_active(v): def lottery(v): lottery_stats, participant_stats = get_active_lottery_stats() return render_template("lottery.html", v=v, lottery_stats=lottery_stats, participant_stats=participant_stats) + +@app.get("/admin/lottery/participants") +@admin_level_required(2) +@lottery_required +def lottery_admin(v): + participants = get_users_participating_in_lottery() + return render_template("admin/lottery.html", v=v, participants=participants) diff --git a/files/templates/admin/admin_home.html b/files/templates/admin/admin_home.html index b38fb03d97..3a04bf7312 100644 --- a/files/templates/admin/admin_home.html +++ b/files/templates/admin/admin_home.html @@ -46,6 +46,13 @@
  • Apps
  • +{% if LOTTERY_ENABLED -%} +

    Lottery

    + +{%- endif %} +

    Statistics