mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
add pagination to subscriber list #131
This commit is contained in:
parent
ff7f89bfce
commit
85939c27d4
2 changed files with 23 additions and 2 deletions
|
@ -955,13 +955,22 @@ def community_moderate_subscribers(actor):
|
|||
if community is not None:
|
||||
if community.is_moderator() or current_user.is_admin():
|
||||
|
||||
page = request.args.get('page', 1, type=int)
|
||||
low_bandwidth = request.cookies.get('low_bandwidth', '0') == '1'
|
||||
|
||||
subscribers = User.query.join(CommunityMember, CommunityMember.user_id == User.id).filter(CommunityMember.community_id == community.id)
|
||||
subscribers = subscribers.filter(CommunityMember.is_banned == False).all()
|
||||
subscribers = subscribers.filter(CommunityMember.is_banned == False)
|
||||
|
||||
# Pagination
|
||||
subscribers = subscribers.paginate(page=page, per_page=100 if not low_bandwidth else 50, error_out=False)
|
||||
next_url = url_for('community.community_moderate_subscribers', actor=actor, page=subscribers.next_num) if subscribers.has_next else None
|
||||
prev_url = url_for('community.community_moderate_subscribers', actor=actor, page=subscribers.prev_num) if subscribers.has_prev and page != 1 else None
|
||||
|
||||
banned_people = User.query.join(CommunityBan, CommunityBan.user_id == User.id).filter(CommunityBan.community_id == community.id).all()
|
||||
|
||||
return render_template('community/community_moderate_subscribers.html', title=_('Moderation of %(community)s', community=community.display_name()),
|
||||
community=community, current='subscribers', subscribers=subscribers, banned_people=banned_people,
|
||||
next_url=next_url, prev_url=prev_url, low_bandwidth=low_bandwidth,
|
||||
moderating_communities=moderating_communities(current_user.get_id()),
|
||||
joined_communities=joined_communities(current_user.get_id()),
|
||||
inoculation=inoculation[randint(0, len(inoculation) - 1)]
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<th>IP</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
{% for user in subscribers %}
|
||||
{% for user in subscribers.items %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/u/{{ user.link() }}">{{ render_username(user) }}</a>
|
||||
|
@ -61,6 +61,18 @@
|
|||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
<nav aria-label="Pagination" class="mt-4" role="navigation">
|
||||
{% if prev_url %}
|
||||
<a href="{{ prev_url }}" class="btn btn-primary" rel="nofollow">
|
||||
<span aria-hidden="true">←</span> {{ _('Previous page') }}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if next_url %}
|
||||
<a href="{{ next_url }}" class="btn btn-primary" rel="nofollow">
|
||||
{{ _('Next page') }} <span aria-hidden="true">→</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
</nav>
|
||||
{% else %}
|
||||
<p>{{ _('This community has no subscribers') }}</p>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in a new issue