make log show 0 actions when u filter by a kind that doesn't exist

(instead of showing all actions)
master
Aevann1 2022-06-13 18:41:46 +02:00
parent 5a0dccbd50
commit d09634bf20
1 changed files with 17 additions and 15 deletions

View File

@ -126,8 +126,10 @@ def log(v):
if v and v.admin_level > 1: types = ACTIONTYPES
else: types = ACTIONTYPES2
if kind not in types: kind = None
if kind and kind not in types:
kind = None
actions = []
else:
actions = g.db.query(ModAction)
if not (v and v.admin_level >= 2):
actions = actions.filter(ModAction.kind.notin_(["shadowban","unshadowban"]))
@ -142,9 +144,9 @@ def log(v):
if kind: actions = actions.filter_by(kind=kind)
actions = actions.order_by(ModAction.id.desc()).offset(25*(page-1)).limit(26).all()
next_exists=len(actions)>25
actions=actions[:25]
admins = [x[0] for x in g.db.query(User.username).filter(User.admin_level >= 2).order_by(User.username).all()]
return render_template("log.html", v=v, admins=admins, types=types, admin=admin, type=kind, actions=actions, next_exists=next_exists, page=page)