use new pagination system in mod log
parent
a0469edfc7
commit
0df074c974
|
@ -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)
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -95,24 +95,7 @@
|
|||
<div class="p-3">There's nothing here right now.</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<nav class="mb-5">
|
||||
<ul class="pagination pagination-sm mb-0">
|
||||
{% if page>1 %}
|
||||
<li class="page-item">
|
||||
<small><a class="page-link" href="{% if sub %}/h/{{sub}}{% endif %}/log?page={{page-1}}{% if admin %}&{{single_user_url}}={{admin}}{% endif %}{% if type %}&kind={{type}}{% endif %}" tabindex="-1">Prev</a></small>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled"><span class="page-link">Prev</span></li>
|
||||
{% endif %}
|
||||
{% if next_exists %}
|
||||
<li class="page-item">
|
||||
<small><a class="page-link" href="{% if sub %}/h/{{sub}}{% endif %}/log?page={{page+1}}{% if admin %}&{{single_user_url}}={{admin}}{% endif %}{% if type %}&kind={{type}}{% endif %}">Next</a></small>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled"><span class="page-link">Next</span></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
{% include "pagination.html" %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue