master
Aevann1 2021-11-24 14:20:52 +02:00
parent b38dbb87c7
commit 2d4e0816d4
2 changed files with 5 additions and 32 deletions

View File

@ -142,26 +142,9 @@ def cached_chart():
@app.get("/paypigs")
@admin_level_required(3)
def patrons(v):
query = g.db.query(
User.id, User.username, User.patron, User.namecolor,
AwardRelationship.kind.label('last_award_kind'), func.count(AwardRelationship.id).label('last_award_count')
).filter(AwardRelationship.submission_id==None, AwardRelationship.comment_id==None, User.patron > 0) \
.group_by(User.username, User.patron, User.id, User.namecolor, AwardRelationship.kind) \
.order_by(User.patron.desc(), AwardRelationship.kind.desc()) \
.join(User).all()
users = g.db.query(User).filter(User.patron > 0).order_by(User.patron.desc()).all()
result = {}
for row in (r._asdict() for r in query):
user_id = row['id']
if user_id not in result:
result[user_id] = row
result[user_id]['awards'] = {}
kind = row['last_award_kind']
if kind in AWARDS.keys():
result[user_id]['awards'][kind] = (AWARDS[kind], row['last_award_count'])
return render_template("patrons.html", v=v, result=result)
return render_template("patrons.html", v=v, users=users)
@app.get("/admins")
@app.get("/badmins")

View File

@ -7,24 +7,14 @@
<th style="font-weight:bold;">#</th>
<th style="font-weight:bold;">Name</th>
<th style="font-weight:bold;">Tier</th>
<th style="font-weight:bold;">Awards</th>
</tr>
</thead>
{% for uid,row in result.items() %}
{% for u in users %}
<tr>
<td style="font-weight:bold;">{{loop.index}}</td>
<td><a style="color:#{{row['namecolor']}}; font-weight:bold;" href="/@{{row['username']}}"><img loading="lazy" src="/uid/{{uid}}/pic" class="pp20"><span {% if row['patron'] %}class="patron" style="background-color:#{{row['namecolor']}};"{% endif %}>{{row['username']}}</span></a></td>
<td><a style="color:#{{u.namecolor}}; font-weight:bold;" href="/@{{u.username}}"><img loading="lazy" src="{{u.profile_url}}" class="pp20"><span {% if u.patron %}class="patron" style="background-color:#{{u.namecolor}};"{% endif %}>{{u.username}}</span></a></td>
<td><img loading="lazy" width=32 height=32 src="/assets/images/badges/patron-{{row['patron']}}.webp?v=1"></td>
<td style="font-weight:bold;">
{% for (a,count) in row['awards'].values() %}
<span class="d-inline-block mx-2 my-1">
<i class="{{a['icon']}} {{a['color']}} fa-fw" data-bs-toggle="tooltip" data-bs-placement="bottom" title="" data-bs-original-title="{{a['title']}} Awards owned"></i>
{{count}}
</span>
{% endfor %}
</td>
<td><img loading="lazy" width=32 height=32 src="/assets/images/badges/patron-{{u.patron}}.webp?v=1"></td>
</tr>
{% endfor %}
</table>