mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-24 03:43:42 -08:00
rework community bans view to show all community subscribers
This commit is contained in:
parent
8c9f91467b
commit
02719db138
4 changed files with 136 additions and 79 deletions
|
@ -911,7 +911,6 @@ def community_notification(community_id: int):
|
||||||
|
|
||||||
return render_template('community/_notification_toggle.html', community=community)
|
return render_template('community/_notification_toggle.html', community=community)
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/<actor>/moderate', methods=['GET'])
|
@bp.route('/<actor>/moderate', methods=['GET'])
|
||||||
@login_required
|
@login_required
|
||||||
def community_moderate(actor):
|
def community_moderate(actor):
|
||||||
|
@ -933,10 +932,13 @@ def community_moderate(actor):
|
||||||
|
|
||||||
next_url = url_for('community.community_moderate', page=reports.next_num) if reports.has_next else None
|
next_url = url_for('community.community_moderate', page=reports.next_num) if reports.has_next else None
|
||||||
prev_url = url_for('community.community_moderate', page=reports.prev_num) if reports.has_prev and page != 1 else None
|
prev_url = url_for('community.community_moderate', page=reports.prev_num) if reports.has_prev and page != 1 else None
|
||||||
|
subscribers = community_subscribers(community.id)
|
||||||
|
subscriber_user_ids = [subscriber.user_id for subscriber in subscribers]
|
||||||
|
subscriber_list = User.query.filter(User.id.in_(subscriber_user_ids)).all()
|
||||||
|
|
||||||
return render_template('community/community_moderate.html', title=_('Moderation of %(community)s', community=community.display_name()),
|
return render_template('community/community_moderate.html', title=_('Moderation of %(community)s', community=community.display_name()),
|
||||||
community=community, reports=reports, current='reports',
|
community=community, reports=reports, current='reports',
|
||||||
next_url=next_url, prev_url=prev_url,
|
next_url=next_url, prev_url=prev_url, subscribers=subscriber_list,
|
||||||
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)]
|
||||||
|
@ -946,18 +948,22 @@ def community_moderate(actor):
|
||||||
else:
|
else:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
@bp.route('/<actor>/moderate/subscribers', methods=['GET'])
|
||||||
@bp.route('/<actor>/moderate/banned', methods=['GET'])
|
|
||||||
@login_required
|
@login_required
|
||||||
def community_moderate_banned(actor):
|
def community_moderate_subscribers(actor):
|
||||||
community = actor_to_community(actor)
|
community = actor_to_community(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():
|
||||||
|
|
||||||
|
subscribers = CommunityMember.query.filter(CommunityMember.community_id == community.id).all()
|
||||||
|
subscriber_user_ids = [subscriber.user_id for subscriber in subscribers]
|
||||||
|
subscriber_list = User.query.filter(User.id.in_(subscriber_user_ids)).all()
|
||||||
|
|
||||||
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_banned.html',
|
|
||||||
title=_('People banned from 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, banned_people=banned_people, current='banned',
|
community=community, current='subscribers', subscribers=subscriber_list, banned_people=banned_people,
|
||||||
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)]
|
||||||
|
@ -967,7 +973,6 @@ def community_moderate_banned(actor):
|
||||||
else:
|
else:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/community/<int:community_id>/moderate_report/<int:report_id>/escalate', methods=['GET', 'POST'])
|
@bp.route('/community/<int:community_id>/moderate_report/<int:report_id>/escalate', methods=['GET', 'POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def community_moderate_report_escalate(community_id, report_id):
|
def community_moderate_report_escalate(community_id, report_id):
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="btn-group mt-3 mb-2">
|
<div class="btn-group mt-3 mb-2 flex-wrap">
|
||||||
{% if community.is_owner() or current_user.is_admin() %}
|
{% if community.is_owner() or current_user.is_admin() %}
|
||||||
<a href="{{ url_for('community.community_edit', community_id=community.id) }}" class="btn {{ 'btn-primary' if current == '' or current == 'edit_settings' else 'btn-outline-secondary' }}" rel="nofollow noindex">
|
<a href="{{ url_for('community.community_edit', community_id=community.id) }}" class="btn {{ 'btn-primary' if current == '' or current == 'edit_settings' else 'btn-outline-secondary' }}" rel="nofollow noindex">
|
||||||
{{ _('Settings') }}
|
{{ _('Settings') }}
|
||||||
|
@ -10,8 +10,8 @@
|
||||||
<a href="/community/{{ community.link() }}/moderate" aria-label="{{ _('Sort by hot') }}" class="btn {{ 'btn-primary' if current == '' or current == 'reports' else 'btn-outline-secondary' }}" rel="nofollow noindex">
|
<a href="/community/{{ community.link() }}/moderate" aria-label="{{ _('Sort by hot') }}" class="btn {{ 'btn-primary' if current == '' or current == 'reports' else 'btn-outline-secondary' }}" rel="nofollow noindex">
|
||||||
{{ _('Reports') }}
|
{{ _('Reports') }}
|
||||||
</a>
|
</a>
|
||||||
<a href="/community/{{ community.link() }}/moderate/banned" class="btn {{ 'btn-primary' if current == 'banned' else 'btn-outline-secondary' }}" rel="nofollow noindex">
|
<a href="/community/{{ community.link() }}/moderate/subscribers" class="btn {{ 'btn-primary' if current == 'subscribers' else 'btn-outline-secondary' }}" rel="nofollow noindex">
|
||||||
{{ _('Banned people') }}
|
{{ _('Subscribers') }}
|
||||||
</a>
|
</a>
|
||||||
<a href="/community/{{ community.link() }}/moderate/appeals" class="btn {{ 'btn-primary' if current == 'appeals' else 'btn-outline-secondary' }} disabled" rel="nofollow noindex" >
|
<a href="/community/{{ community.link() }}/moderate/appeals" class="btn {{ 'btn-primary' if current == 'appeals' else 'btn-outline-secondary' }} disabled" rel="nofollow noindex" >
|
||||||
{{ _('Appeals') }}
|
{{ _('Appeals') }}
|
||||||
|
|
|
@ -1,67 +0,0 @@
|
||||||
{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %}
|
|
||||||
{% extends 'themes/' + theme() + '/base.html' %}
|
|
||||||
{% else %}
|
|
||||||
{% extends "base.html" %}
|
|
||||||
{% endif %} %}
|
|
||||||
{% from 'bootstrap/form.html' import render_field %}
|
|
||||||
|
|
||||||
{% block app_content %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12 col-md-8 position-relative main_pane">
|
|
||||||
<nav aria-label="breadcrumb" id="breadcrumb_nav" title="Navigation">
|
|
||||||
<ol class="breadcrumb">
|
|
||||||
<li class="breadcrumb-item"><a href="/">{{ _('Home') }}</a></li>
|
|
||||||
<li class="breadcrumb-item"><a href="{{ url_for('activitypub.community_profile', actor=community.ap_id if community.ap_id is not none else community.name) }}">{{ (community.title + '@' + community.ap_domain)|shorten }}</a></li>
|
|
||||||
<li class="breadcrumb-item active">{{ _('Moderation') }}</li>
|
|
||||||
</ol>
|
|
||||||
</nav>
|
|
||||||
{% include "community/_community_moderation_nav.html" %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12 col-md-10">
|
|
||||||
<h1 class="mt-2">{{ _('Banned people') }}</h1>
|
|
||||||
</div>
|
|
||||||
<div class="col-12 col-md-2 text-right">
|
|
||||||
<!-- <a class="btn btn-primary" href="{{ url_for('community.community_add_moderator', community_id=community.id) }}">{{ _('Add moderator') }}</a> -->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<p>{{ _('See and manage who is banned from %(community)s', community=community.display_name()) }}</p>
|
|
||||||
<h2></h2>
|
|
||||||
{% if banned_people %}
|
|
||||||
<form method="get">
|
|
||||||
<input type="search" name="search" value="{{ search }}">
|
|
||||||
<input type="radio" name="local_remote" value="local" id="local_remote_local" {{ 'checked' if local_remote == 'local' }}><label for="local_remote_local"> Local</label>
|
|
||||||
<input type="radio" name="local_remote" value="remote" id="local_remote_remote" {{ 'checked' if local_remote == 'remote' }}><label for="local_remote_remote"> Remote</label>
|
|
||||||
<input type="submit" name="submit" value="Search" class="btn btn-primary">
|
|
||||||
</form>
|
|
||||||
<table class="table table-striped mt-1">
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Local/Remote</th>
|
|
||||||
<th>Reports</th>
|
|
||||||
<th>IP</th>
|
|
||||||
<th>Actions</th>
|
|
||||||
</tr>
|
|
||||||
{% for user in banned_people %}
|
|
||||||
<tr>
|
|
||||||
<td><img src="{{ user.avatar_thumbnail() }}" class="community_icon rounded-circle" loading="lazy" />
|
|
||||||
{{ user.display_name() }}</td>
|
|
||||||
<td>{{ 'Local' if user.is_local() else 'Remote' }}</td>
|
|
||||||
<td>{{ user.reports if user.reports > 0 }} </td>
|
|
||||||
<td>{{ user.ip_address if user.ip_address }} </td>
|
|
||||||
<td>{% if user.is_local() %}
|
|
||||||
<a href="/u/{{ user.link() }}">View</a>
|
|
||||||
{% else %}
|
|
||||||
<a href="/u/{{ user.link() }}">View local</a> |
|
|
||||||
<a href="{{ user.ap_profile_id }}">View remote</a>
|
|
||||||
{% endif %}
|
|
||||||
| <a href="{{ url_for('community.community_unban_user', community_id=community.id, user_id=user.id) }}" class="confirm_first">{{ _('Un ban') }}</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
{% else %}
|
|
||||||
<p>{{ _('No banned people yet') }}</p>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
119
app/templates/community/community_moderate_subscribers.html
Normal file
119
app/templates/community/community_moderate_subscribers.html
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %}
|
||||||
|
{% extends 'themes/' + theme() + '/base.html' %}
|
||||||
|
{% else %}
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% endif %} %}
|
||||||
|
{% from 'bootstrap/form.html' import render_field %}
|
||||||
|
|
||||||
|
{% block app_content %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 col-md-8 position-relative main_pane">
|
||||||
|
<nav aria-label="breadcrumb" id="breadcrumb_nav" title="Navigation">
|
||||||
|
<ol class="breadcrumb">
|
||||||
|
<li class="breadcrumb-item"><a href="/">{{ _('Home') }}</a></li>
|
||||||
|
<li class="breadcrumb-item"><a href="{{ url_for('activitypub.community_profile', actor=community.ap_id if community.ap_id is not none else community.name) }}">{{ (community.title + '@' + community.ap_domain)|shorten }}</a></li>
|
||||||
|
<li class="breadcrumb-item active">{{ _('Moderation') }}</li>
|
||||||
|
</ol>
|
||||||
|
</nav>
|
||||||
|
{% include "community/_community_moderation_nav.html" %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 col-md-10">
|
||||||
|
<h1 class="mt-2">{{ _('Subscribers') }}</h1>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-md-2 text-right">
|
||||||
|
<!-- <a class="btn btn-primary" href="{{ url_for('community.community_add_moderator', community_id=community.id) }}">{{ _('Add moderator') }}</a> -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p>{{ _('See who is subscribed to %(community)s', community=community.display_name()) }}</p>
|
||||||
|
<h2></h2>
|
||||||
|
{% if subscribers %}
|
||||||
|
<div class="table-responsive-lg">
|
||||||
|
<table class="table table-striped mt-1">
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Local/Remote</th>
|
||||||
|
<th>About</th>
|
||||||
|
<th>Last Seen</th>
|
||||||
|
<th>IP</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
{% for user in subscribers %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="/u/{{ user.link() }}">{{ render_username(user) }}</a>
|
||||||
|
</td>
|
||||||
|
<td>{% if user.is_local() %} Local {% else %} <a href="{{ user.ap_profile_id }}">{{ user.ap_domain }}</a>{% endif %}</td>
|
||||||
|
<td>{{ user.about_html | safe if user.about_html }} </td>
|
||||||
|
<td>{{ moment(user.last_seen).fromNow() }} </td>
|
||||||
|
<td>{{ user.ip_address if user.ip_address }} </td>
|
||||||
|
<td>
|
||||||
|
<div class="dropdown">
|
||||||
|
<button class="btn btn-primary btn-sm dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
|
Actions
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
{% if user.is_local() %}<li><a class="dropdown-item" href="/chat/{{ user.id }}/new">Send Message</a></li>{% endif %}
|
||||||
|
<li><a class="dropdown-item" href="/u/{{ user.link() }}/report">Report</a></li>
|
||||||
|
<div class="dropdown-divider"></div>
|
||||||
|
<li><a class="dropdown-item" href="{{ url_for('community.community_ban_user', community_id=community.id, user_id=user.id) }}" class="confirm_first">{{ _('Ban') }}</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<p>{{ _('This community has no subscribers') }}</p>
|
||||||
|
{% endif %}
|
||||||
|
<h1 class="mt-2">{{ _('Banned People') }}</h1>
|
||||||
|
<p>{{ _('See and manage who is banned from %(community)s', community=community.display_name()) }}</p>
|
||||||
|
{% if banned_people %}
|
||||||
|
<form method="get">
|
||||||
|
<input type="search" name="search" value="{{ search }}">
|
||||||
|
<input type="radio" name="local_remote" value="local" id="local_remote_local" {{ 'checked' if local_remote == 'local' }}><label for="local_remote_local"> Local</label>
|
||||||
|
<input type="radio" name="local_remote" value="remote" id="local_remote_remote" {{ 'checked' if local_remote == 'remote' }}><label for="local_remote_remote"> Remote</label>
|
||||||
|
<input type="submit" name="submit" value="Search" class="btn btn-primary">
|
||||||
|
</form>
|
||||||
|
<div class="table-responsive-lg">
|
||||||
|
<table class="table table-striped mt-1">
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Local/Remote</th>
|
||||||
|
<th>Reports</th>
|
||||||
|
<th>IP</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
{% for user in banned_people %}
|
||||||
|
<tr>
|
||||||
|
<td><a href="/u/{{ user.link() }}">{{ render_username(user) }}</a></td>
|
||||||
|
<td>{% if user.is_local() %} Local {% else %} <a href="{{ user.ap_profile_id }}">{{ user.ap_domain }}</a>{% endif %}</td>
|
||||||
|
<td>{{ user.reports if user.reports > 0 }} </td>
|
||||||
|
<td>{{ user.ip_address if user.ip_address }} </td>
|
||||||
|
<td>
|
||||||
|
<div class="dropdown">
|
||||||
|
<button class="btn btn-primary btn-sm dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
|
Actions
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
{% if user.is_local() %}<li><a class="dropdown-item" href="/chat/{{ user.id }}/new">Send Message</a></li>
|
||||||
|
<li><a class="dropdown-item" href="/u/{{ user.link() }}">View</a></li>
|
||||||
|
{% else %}
|
||||||
|
<li><a class="dropdown-item" href="/u/{{ user.link() }}">View local</a> </li>
|
||||||
|
<li><a class="dropdown-item"href="{{ user.ap_profile_id }}">View remote</a></li>
|
||||||
|
{% endif %}
|
||||||
|
<div class="dropdown-divider"></div>
|
||||||
|
<li><a class="dropdown-item" href="{{ url_for('community.community_unban_user', community_id=community.id, user_id=user.id) }}" class="confirm_first">{{ _('Unban') }}</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<p>{{ _('No banned people yet') }}</p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
Loading…
Add table
Reference in a new issue