From d88ee942f421af321bb14d73d0cc7a70cd54afc7 Mon Sep 17 00:00:00 2001 From: Aevann Date: Mon, 21 Oct 2024 18:28:23 +0300 Subject: [PATCH] add "Moderation History" button --- files/routes/static.py | 18 +++++++++++++++++- files/templates/userpage/admintools.html | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/files/routes/static.py b/files/routes/static.py index fc62978ab..434e91626 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -1,7 +1,7 @@ import os from shutil import copyfile -from sqlalchemy import func, text +from sqlalchemy import func, text, or_ from files.helpers.media import * import files.helpers.stats as statshelper @@ -243,6 +243,8 @@ def log(v): if admin: admin_id = get_user(admin, attributes=[User.id]).id else: admin_id = 0 + target_id = int(request.values.get("target_id", 0)) + kind = request.values.get("kind") if v.admin_level >= PERMS['USER_SHADOWBAN']: @@ -270,6 +272,20 @@ def log(v): for k,val in types.items(): if k in kinds: types2[k] = val types = types2 + if target_id: + target_post_ids = [x[0] for x in g.db.query(Post.id).filter_by(author_id=target_id)] + target_comment_ids = [x[0] for x in g.db.query(Comment.id).filter_by(author_id=target_id)] + actions = actions.filter(or_( + ModAction.target_user_id == target_id, + ModAction.target_post_id.in_(target_post_ids), + ModAction.target_comment_id.in_(target_comment_ids), + )) + kinds = {x.kind for x in actions} + kinds.add(kind) + types2 = {} + for k,val in types.items(): + if k in kinds: types2[k] = val + types = types2 if kind: actions = actions.filter_by(kind=kind) total = actions.count() actions = actions.order_by(ModAction.id.desc()).offset(PAGE_SIZE*(page-1)).limit(PAGE_SIZE).all() diff --git a/files/templates/userpage/admintools.html b/files/templates/userpage/admintools.html index 45bd1efde..7fcf22604 100644 --- a/files/templates/userpage/admintools.html +++ b/files/templates/userpage/admintools.html @@ -92,6 +92,8 @@ {% endif %}
+ Moderation History + {% if FEATURES['BADGES'] and v.admin_level >= PERMS['USER_BADGES'] %} Give Badge Remove Badge