From 04a42899ccdd33d65f12f3ff96f65ffba8ecfd4e Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 8 Nov 2024 21:38:21 +0200 Subject: [PATCH] better counter --- files/routes/groups.py | 6 ++++-- files/templates/group_memberships.html | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/files/routes/groups.py b/files/routes/groups.py index 11850e193..a42953e90 100644 --- a/files/routes/groups.py +++ b/files/routes/groups.py @@ -177,7 +177,9 @@ def memberships(v, group_name): GroupMembership.user_id != group.owner_id, ) total = members.count() - members = members.order_by(GroupMembership.is_mod.desc(), GroupMembership.approved_utc).offset(500 * (page - 1)).limit(500).all() + if page == 1: size = 499 + else: size = 500 + members = members.order_by(GroupMembership.is_mod.desc(), GroupMembership.approved_utc).offset(size * (page - 1)).limit(size).all() if page == 1: owner = [g.db.query(GroupMembership).join(GroupMembership.user).filter( @@ -192,7 +194,7 @@ def memberships(v, group_name): GroupMembership.approved_utc == None ).order_by(GroupMembership.created_utc).all() - return render_template('group_memberships.html', v=v, group=group, members=members, applications=applications, page=page, total=total, size=500) + return render_template('group_memberships.html', v=v, group=group, members=members, applications=applications, page=page, total=total, size=size) @app.post("/!//approve") @limiter.limit('1/second', scope=rpath) diff --git a/files/templates/group_memberships.html b/files/templates/group_memberships.html index a28f2444d..d559f593f 100644 --- a/files/templates/group_memberships.html +++ b/files/templates/group_memberships.html @@ -77,8 +77,8 @@ {% for membership in memberships %} {% set counter = loop.index %} - {% if name == 'members' and page > 1 %} - {% set counter = counter + (page - 1) * 500 + 1 %} + {% if name == 'members' %} + {% set counter = counter + (page - 1) * 500 %} {% endif %} {{counter}} {% set is_owner = membership.user_id == group.owner_id %}