Add 'added' column to /marseys.

master
Snakes 2022-10-01 18:27:51 -04:00
parent efed874d3c
commit cd0b564401
Signed by: Snakes
GPG Key ID: E745A82778055C7E
2 changed files with 9 additions and 3 deletions

View File

@ -4,7 +4,7 @@ from files.helpers.alerts import *
from files.helpers.const import * from files.helpers.const import *
from files.helpers.actions import * from files.helpers.actions import *
from files.classes.award import AWARDS from files.classes.award import AWARDS
from sqlalchemy import func from sqlalchemy import func, nullslast
import os import os
from files.classes.mod_logs import ACTIONTYPES, ACTIONTYPES2 from files.classes.mod_logs import ACTIONTYPES, ACTIONTYPES2
from files.classes.badges import BadgeDef from files.classes.badges import BadgeDef
@ -25,8 +25,12 @@ def marseys(v):
if SITE == 'rdrama.net': if SITE == 'rdrama.net':
marseys = g.db.query(Marsey, User).join(User, Marsey.author_id == User.id).filter(Marsey.submitter_id==None) marseys = g.db.query(Marsey, User).join(User, Marsey.author_id == User.id).filter(Marsey.submitter_id==None)
sort = request.values.get("sort", "usage") sort = request.values.get("sort", "usage")
if sort == "usage": marseys = marseys.order_by(Marsey.count.desc(), User.username).all() if sort == "usage":
else: marseys = marseys.order_by(User.username, Marsey.count.desc()).all() marseys = marseys.order_by(Marsey.count.desc(), User.username).all()
elif sort == "added":
marseys = marseys.order_by(nullslast(Marsey.created_utc.desc()), User.username).all()
else: # implied sort == "author"
marseys = marseys.order_by(User.username, Marsey.count.desc()).all()
original = os.listdir("/asset_submissions/marseys/original") original = os.listdir("/asset_submissions/marseys/original")
for marsey, user in marseys: for marsey, user in marseys:

View File

@ -13,6 +13,7 @@
<th>Usage</th> <th>Usage</th>
{% if SITE == 'rdrama.net' %} {% if SITE == 'rdrama.net' %}
<th><a href="?sort=author">Author</a></th> <th><a href="?sort=author">Author</a></th>
<th><a href="?sort=added">Added</a></th>
<th>Original File</th> <th>Original File</th>
{% endif %} {% endif %}
</tr> </tr>
@ -26,6 +27,7 @@
<td><img class="marsey" loading="lazy" data-bs-toggle="tooltip" alt=":#{{marsey.name}}:" title=":{{marsey.name}}:" src="/e/{{marsey.name}}.webp"></td> <td><img class="marsey" loading="lazy" data-bs-toggle="tooltip" alt=":#{{marsey.name}}:" title=":{{marsey.name}}:" src="/e/{{marsey.name}}.webp"></td>
<td>{{marsey.count}}</td> <td>{{marsey.count}}</td>
<td>{% include "user_in_table.html" %}</td> <td>{% include "user_in_table.html" %}</td>
<td {% if marsey.created_utc != None %}data-time="{{marsey.created_utc}}"{% endif %}></td>
<td> <td>
{% if marsey.og %} {% if marsey.og %}
<a href="/asset_submissions/marseys/original/{{marsey.og}}">{{marsey.og}}</a> <a href="/asset_submissions/marseys/original/{{marsey.og}}">{{marsey.og}}</a>