forked from rDrama/rDrama
add the ability to order hats by author username
parent
7785f049ec
commit
93d7c91ce7
|
@ -13,6 +13,11 @@ def hats(v):
|
||||||
|
|
||||||
owned_hat_ids = [x.hat_id for x in v.owned_hats]
|
owned_hat_ids = [x.hat_id for x in v.owned_hats]
|
||||||
|
|
||||||
|
if request.values.get("sort") == 'author_asc':
|
||||||
|
hats = g.db.query(HatDef, User).join(HatDef.author).order_by(User.username).all()
|
||||||
|
elif request.values.get("sort") == 'author_desc':
|
||||||
|
hats = g.db.query(HatDef, User).join(HatDef.author).order_by(User.username.desc()).all()
|
||||||
|
else:
|
||||||
if v.equipped_hat_ids:
|
if v.equipped_hat_ids:
|
||||||
equipped = g.db.query(HatDef, User).join(HatDef.author).filter(HatDef.id.in_(owned_hat_ids), HatDef.id.in_(v.equipped_hat_ids)).order_by(HatDef.price, HatDef.name).all()
|
equipped = g.db.query(HatDef, User).join(HatDef.author).filter(HatDef.id.in_(owned_hat_ids), HatDef.id.in_(v.equipped_hat_ids)).order_by(HatDef.price, HatDef.name).all()
|
||||||
not_equipped = g.db.query(HatDef, User).join(HatDef.author).filter(HatDef.id.in_(owned_hat_ids), HatDef.id.notin_(v.equipped_hat_ids)).order_by(HatDef.price, HatDef.name).all()
|
not_equipped = g.db.query(HatDef, User).join(HatDef.author).filter(HatDef.id.in_(owned_hat_ids), HatDef.id.notin_(v.equipped_hat_ids)).order_by(HatDef.price, HatDef.name).all()
|
||||||
|
|
|
@ -41,7 +41,11 @@
|
||||||
<th scope="col">Name</th>
|
<th scope="col">Name</th>
|
||||||
<th scope="col">Description</th>
|
<th scope="col">Description</th>
|
||||||
{% if SITE == 'rdrama.net' %}
|
{% if SITE == 'rdrama.net' %}
|
||||||
<th scope="col">Author</th>
|
{% if request.values.get("sort") == 'author_asc' %}
|
||||||
|
<th scope="col"><a href="?sort=author_desc">Author</a></th>
|
||||||
|
{% else %}
|
||||||
|
<th scope="col"><a href="?sort=author_desc">Author</a></th>
|
||||||
|
{% endif %}
|
||||||
<th scope="col" onclick="sort_table(4)">Owners</th>
|
<th scope="col" onclick="sort_table(4)">Owners</th>
|
||||||
<th scope="col" onclick="sort_table(5)">Price</th>
|
<th scope="col" onclick="sort_table(5)">Price</th>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
Loading…
Reference in New Issue