master
Aevann1 2021-09-08 10:53:57 +02:00
parent d55e9e4557
commit 29e99f7ebc
7 changed files with 264 additions and 223 deletions

View File

@ -56,7 +56,22 @@ else:
@app.get("/shop")
@auth_required
def shop(v):
return render_template("shop.html", awards=list(AWARDS.values()), v=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).filter(User.id == v.id).all()
owned = {}
for row in (r._asdict() for r in query):
kind = row['last_award_kind']
if kind in AWARDS.keys():
owned[kind] = (AWARDS[kind], row['last_award_count'])
print(owned.values())
return render_template("shop.html", owned=owned.values(), awards=list(AWARDS.values()), v=v)
@app.post("/buy/<award>")
@auth_required

View File

@ -33,6 +33,32 @@
<pre></pre>
<pre></pre>
<h5>Owned</h5>
<table class="table table-striped">
<thead class="bg-primary text-white">
<tr>
<th scope="col">Icon</th>
<th scope="col">Title</th>
<th scope="col">Number</th>
</tr>
</thead>
<tbody>
{% for a in awards %}
<tr>
<td><i class="{{a['icon']}} {{a['color']}}" style="font-size: 30px"></i></td>
<td style="font-weight: bold">{{a['title']}}</td>
<td style="font-weight: bold">{{a['price']}}</td>
{% set kind = a['kind'] %}
</tr>
{% endfor %}
</table>
<pre>
</pre>
<h5>Shop</h5>
<table class="table table-striped">