forked from MarseyWorld/MarseyWorld
add "Moderation History" button
parent
07a0c54a87
commit
d88ee942f4
|
@ -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()
|
||||
|
|
|
@ -92,6 +92,8 @@
|
|||
{% endif %}
|
||||
|
||||
<div class="actionbtns my-3">
|
||||
<a id="moderation-history-{{deviceType}}" class="btn btn-primary" style="display:inline-block!important" href="/log?target_id={{u.id}}">Moderation History</a>
|
||||
|
||||
{% if FEATURES['BADGES'] and v.admin_level >= PERMS['USER_BADGES'] %}
|
||||
<a id="give-badge-{{deviceType}}" class="btn btn-primary" style="display:inline-block!important" href="/admin/badge_grant?usernames={{u.username}}">Give Badge</a>
|
||||
<a id="remove-badge-{{deviceType}}" class="btn btn-primary" style="display:inline-block!important" href="/admin/badge_remove?usernames={{u.username}}">Remove Badge</a>
|
||||
|
|
Loading…
Reference in New Issue