forked from MarseyWorld/MarseyWorld
parent
3c6d539daf
commit
0a468b4b0b
|
@ -1,6 +1,8 @@
|
|||
from files.mail import *
|
||||
from files.__main__ import app, limiter
|
||||
from files.helpers.alerts import *
|
||||
from files.classes.award import AWARDS
|
||||
from sqlalchemy import func
|
||||
|
||||
site = environ.get("DOMAIN").strip()
|
||||
site_name = environ.get("SITE_NAME").strip()
|
||||
|
@ -43,9 +45,25 @@ def participation_stats(v):
|
|||
@app.get("/paypigs")
|
||||
@auth_desired
|
||||
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) \
|
||||
.group_by(User.username, User.patron, User.id, User.namecolor, AwardRelationship.kind) \
|
||||
.order_by(User.patron.desc(), AwardRelationship.kind.asc()) \
|
||||
.join(User).all()
|
||||
|
||||
users = g.db.query(User).options(lazyload('*')).filter(User.patron > 0).order_by(User.patron.desc()).all()
|
||||
return render_template("patrons.html", v=v, users=users)
|
||||
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'] = {}
|
||||
|
||||
result[user_id]['awards'][row['last_award_kind']] = (AWARDS[row['last_award_kind']],
|
||||
row['last_award_count'])
|
||||
|
||||
return render_template("patrons.html", v=v, result=result)
|
||||
|
||||
@app.get("/admins")
|
||||
@auth_desired
|
||||
|
|
|
@ -10,18 +10,18 @@
|
|||
<th style="font-weight:bold;">Awards</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for user in users %}
|
||||
{% for uid,row in result.items() %}
|
||||
<tr>
|
||||
<td style="font-weight:bold;">{{users.index(user)+1}}</td>
|
||||
<td><a style="color:#{{user.namecolor}}; font-weight:bold;" href="/@{{user.username}}"><img src="/uid/{{user.id}}/pic/profile" class="profile-pic-20 mr-1"><span {% if user.patron %}class="patron" style="background-color:#{{user.namecolor}};"{% endif %}>{{user.username}}</span></a></td>
|
||||
<td style="font-weight:bold;">{{loop.index}}</td>
|
||||
<td><a style="color:#{{row['namecolor']}}; font-weight:bold;" href="/@{{row['username']}}"><img src="/uid/{{uid}}/pic/profile" class="profile-pic-20 mr-1"><span {% if row['patron'] %}class="patron" style="background-color:#{{row['namecolor']}};"{% endif %}>{{row['username']}}</span></a></td>
|
||||
|
||||
<td><img style="width: 32px; height: 32px" src="/assets/images/badges/patron-{{user.patron}}.gif"></td>
|
||||
<td><img style="width: 32px; height: 32px" src="/assets/images/badges/patron-{{row['patron']}}.gif"></td>
|
||||
|
||||
<td style="font-weight:bold;">
|
||||
{% for a in user.display_awards %}
|
||||
{% 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-toggle="tooltip" data-placement="bottom" title="{{a['title']}} Awards owned"></i>
|
||||
{{a['count']}}
|
||||
{{count}}
|
||||
</span>
|
||||
{% endfor %}
|
||||
</td>
|
||||
|
|
Loading…
Reference in New Issue