mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-24 03:43:42 -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 not None:
|
||||||
if community.is_moderator() or current_user.is_admin():
|
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 = 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()
|
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()),
|
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,
|
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()),
|
moderating_communities=moderating_communities(current_user.get_id()),
|
||||||
joined_communities=joined_communities(current_user.get_id()),
|
joined_communities=joined_communities(current_user.get_id()),
|
||||||
inoculation=inoculation[randint(0, len(inoculation) - 1)]
|
inoculation=inoculation[randint(0, len(inoculation) - 1)]
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
<th>IP</th>
|
<th>IP</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for user in subscribers %}
|
{% for user in subscribers.items %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="/u/{{ user.link() }}">{{ render_username(user) }}</a>
|
<a href="/u/{{ user.link() }}">{{ render_username(user) }}</a>
|
||||||
|
@ -61,6 +61,18 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</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 %}
|
{% else %}
|
||||||
<p>{{ _('This community has no subscribers') }}</p>
|
<p>{{ _('This community has no subscribers') }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Add table
Reference in a new issue