diff --git a/files/routes/static.py b/files/routes/static.py index 5aba367ed..90408e99f 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -169,6 +169,7 @@ def log(v:User): if kind and kind not in types: kind = None actions = [] + next_exists = 0 else: actions = g.db.query(ModAction) if v.admin_level < PERMS['USER_SHADOWBAN']: @@ -184,11 +185,9 @@ def log(v:User): if k in kinds: types2[k] = val types = types2 if kind: actions = actions.filter_by(kind=kind) + next_exists = actions.count() + actions = actions.order_by(ModAction.id.desc()).offset(PAGE_SIZE*(page-1)).limit(PAGE_SIZE).all() - actions = actions.order_by(ModAction.id.desc()).offset(PAGE_SIZE*(page-1)).limit(PAGE_SIZE+1).all() - - next_exists=len(actions) > PAGE_SIZE - actions=actions[:PAGE_SIZE] admins = [x[0] for x in g.db.query(User.username).filter(User.admin_level >= PERMS['ADMIN_MOP_VISIBLE']).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, single_user_url='admin') @@ -217,7 +216,7 @@ def log_item(id, v): types = MODACTION_TYPES__FILTERED else: types = MODACTION_TYPES_FILTERED - return render_template("log.html", v=v, actions=[action], next_exists=False, page=1, action=action, admins=admins, types=types, single_user_url='admin') + return render_template("log.html", v=v, actions=[action], next_exists=1, page=1, action=action, admins=admins, types=types, single_user_url='admin') @app.get("/directory") @limiter.limit(DEFAULT_RATELIMIT) diff --git a/files/routes/subs.py b/files/routes/subs.py index e6633f539..fc1d4084d 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -867,6 +867,7 @@ def hole_log(v:User, sub): if kind and kind not in types: kind = None actions = [] + next_exists=0 else: actions = g.db.query(SubAction).filter_by(sub=sub.name) @@ -878,11 +879,9 @@ def hole_log(v:User, sub): if k in kinds: types2[k] = val types = types2 if kind: actions = actions.filter_by(kind=kind) + next_exists = actions.count() + actions = actions.order_by(SubAction.id.desc()).offset(PAGE_SIZE*(page-1)).limit(PAGE_SIZE).all() - actions = actions.order_by(SubAction.id.desc()).offset(PAGE_SIZE*(page-1)).limit(PAGE_SIZE+1).all() - - next_exists=len(actions)>25 - actions=actions[:25] mods = [x[0] for x in g.db.query(Mod.user_id).filter_by(sub=sub.name).all()] mods = [x[0] for x in g.db.query(User.username).filter(User.id.in_(mods)).order_by(User.username).all()] @@ -908,4 +907,4 @@ def hole_log_item(id, v, sub): types = SUBACTION_TYPES - return render_template("log.html", v=v, actions=[action], next_exists=False, page=1, action=action, admins=mods, types=types, sub=sub, single_user_url='mod') + return render_template("log.html", v=v, actions=[action], next_exists=1, page=1, action=action, admins=mods, types=types, sub=sub, single_user_url='mod') diff --git a/files/templates/log.html b/files/templates/log.html index 6ee1d6309..e7bdf22cf 100644 --- a/files/templates/log.html +++ b/files/templates/log.html @@ -95,24 +95,7 @@
There's nothing here right now.
{% endfor %} - + {% include "pagination.html" %}