forked from MarseyWorld/MarseyWorld
dfsfds
parent
0f672dc934
commit
d686b53c4e
|
@ -1,6 +1,31 @@
|
||||||
from files.classes import *
|
from files.classes import *
|
||||||
from flask import g
|
from flask import g
|
||||||
|
|
||||||
|
|
||||||
|
def get_id(username, v=None, graceful=False):
|
||||||
|
|
||||||
|
username = username.replace('\\', '')
|
||||||
|
username = username.replace('_', '\_')
|
||||||
|
username = username.replace('%', '')
|
||||||
|
|
||||||
|
user = g.db.query(
|
||||||
|
User.id
|
||||||
|
).filter(
|
||||||
|
or_(
|
||||||
|
User.username.ilike(username),
|
||||||
|
User.original_username.ilike(username)
|
||||||
|
)
|
||||||
|
).first()
|
||||||
|
|
||||||
|
if not user:
|
||||||
|
if not graceful:
|
||||||
|
abort(404)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return user[0]
|
||||||
|
|
||||||
|
|
||||||
def get_user(username, v=None, graceful=False):
|
def get_user(username, v=None, graceful=False):
|
||||||
|
|
||||||
username = username.replace('\\', '')
|
username = username.replace('\\', '')
|
||||||
|
|
|
@ -175,15 +175,20 @@ def admins(v):
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def log(v):
|
def log(v):
|
||||||
|
|
||||||
page=int(request.args.get("page",1))
|
page = int(request.args.get("page",1))
|
||||||
admin=int(request.args.get("admin",0))
|
admin = request.args.get("admin")
|
||||||
|
if admin: admin = get_id(admin)
|
||||||
|
|
||||||
if v and v.admin_level > 1: actions = g.db.query(ModAction).order_by(ModAction.id.desc()).offset(25 * (page - 1)).limit(26)
|
kind = request.args.get("kind")
|
||||||
else: actions=g.db.query(ModAction).filter(ModAction.kind!="shadowban", ModAction.kind!="unshadowban", ModAction.kind!="club", ModAction.kind!="unclub", ModAction.kind!="check").order_by(ModAction.id.desc()).offset(25*(page-1)).limit(26)
|
|
||||||
|
|
||||||
if admin: actions = actions.filter_by(user_id=admin)
|
actions = g.db.query(ModAction)
|
||||||
|
if not (v and v.admin_level > 1):
|
||||||
|
actions = actions.filter(ModAction.kind!="shadowban", ModAction.kind!="unshadowban", ModAction.kind!="club", ModAction.kind!="unclub", ModAction.kind!="check")
|
||||||
|
|
||||||
actions = actions.all()
|
if admin: actions = actions.filter_by(user_id=admin)
|
||||||
|
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
|
next_exists=len(actions)>25
|
||||||
actions=actions[:25]
|
actions=actions[:25]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue