forked from rDrama/rDrama
Lottery: add admin participants listing.
parent
193adb82d2
commit
49622b3268
|
@ -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():
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -46,6 +46,13 @@
|
|||
<li><a href="/admin/apps">Apps</a></li>
|
||||
</ul>
|
||||
|
||||
{% if LOTTERY_ENABLED -%}
|
||||
<h4>Lottery</h4>
|
||||
<ul>
|
||||
<li><a href="/admin/lottery/participants">Participants</a></li>
|
||||
</ul>
|
||||
{%- endif %}
|
||||
|
||||
<h4>Statistics</h4>
|
||||
<ul>
|
||||
<li><a href="/stats">Content Stats</a></li>
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
{% extends "default.html" %}
|
||||
|
||||
{% block content %}
|
||||
<pre></pre>
|
||||
<h5>Admin — Lottery Info</h5>
|
||||
<pre></pre>
|
||||
<div class="overflow-x-auto"><table class="table table-striped mb-5">
|
||||
<thead class="bg-primary text-white">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Name</th>
|
||||
<th>Tickets Held</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for user in participants %}
|
||||
<tr>
|
||||
<td>{{loop.index}}</td>
|
||||
<td><a style="color:#{{user.namecolor}}" href="/@{{user.username}}"><img loading="lazy" src="{{user.profile_url}}" class="pp20"><span {% if user.patron %}class="patron" style="background-color:#{{user.namecolor}}"{% endif %}>{{user.username}}</span></a></td>
|
||||
<td>{{user.currently_held_lottery_tickets}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue