mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 01:51:08 +00:00
Let moderators delete users
This commit is contained in:
parent
916be2552d
commit
15344b6a8e
4 changed files with 27 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
|||
{% load i18n %}
|
||||
<div class="block content">
|
||||
{% if not user.is_active and user.deactivation_reason == "self_deletion" %}
|
||||
{% if not user.is_active and user.deactivation_reason == "self_deletion" or user.deactivation_reason == "moderator_deletion" %}
|
||||
<div class="notification is-danger">
|
||||
{% trans "Permanently deleted" %}
|
||||
</div>
|
||||
|
@ -15,23 +15,31 @@
|
|||
{% endif %}
|
||||
|
||||
{% if user.is_active or user.deactivation_reason == "pending" %}
|
||||
|
||||
<form name="suspend" method="post" action="{% url 'settings-report-suspend' user.id %}">
|
||||
<form name="suspend" method="post" action="{% url 'settings-report-suspend' user.id %}" class="mr-1">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="button is-danger is-light">{% trans "Suspend user" %}</button>
|
||||
</form>
|
||||
|
||||
{% else %}
|
||||
|
||||
<form name="unsuspend" method="post" action="{% url 'settings-report-unsuspend' user.id %}">
|
||||
<form name="unsuspend" method="post" action="{% url 'settings-report-unsuspend' user.id %}" class="mr-1">
|
||||
{% csrf_token %}
|
||||
<button class="button">{% trans "Un-suspend user" %}</button>
|
||||
</form>
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% if user.local %}
|
||||
<div>
|
||||
{% trans "Permanently delete user" as button_text %}
|
||||
{% include "snippets/toggle/open_button.html" with controls_text="delete_user" text=button_text class="is-danger is-light" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if user.local %}
|
||||
<div>
|
||||
{% include "user_admin/delete_user_form.html" with controls_text="delete_user" class="mt-2 mb-2" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if user.local %}
|
||||
<div>
|
||||
<form name="permission" method="post" action="{% url 'settings-user' user.id %}">
|
||||
|
|
|
@ -158,6 +158,11 @@ urlpatterns = [
|
|||
views.unsuspend_user,
|
||||
name="settings-report-unsuspend",
|
||||
),
|
||||
re_path(
|
||||
r"^settings/reports/(?P<user_id>\d+)/delete/?$",
|
||||
views.moderator_delete_user,
|
||||
name="settings-delete-user",
|
||||
),
|
||||
re_path(
|
||||
r"^settings/reports/(?P<report_id>\d+)/resolve/?$",
|
||||
views.resolve_report,
|
||||
|
|
|
@ -40,6 +40,7 @@ from .reports import (
|
|||
resolve_report,
|
||||
suspend_user,
|
||||
unsuspend_user,
|
||||
moderator_delete_user,
|
||||
)
|
||||
from .rss_feed import RssFeed
|
||||
from .password import PasswordResetRequest, PasswordReset, ChangePassword
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
""" moderation via flagged posts and users """
|
||||
from django.contrib.auth.decorators import login_required, permission_required
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.template.response import TemplateResponse
|
||||
from django.utils.decorators import method_decorator
|
||||
|
@ -101,6 +102,11 @@ def unsuspend_user(_, user_id):
|
|||
def moderator_delete_user(request, user_id):
|
||||
"""permanently delete a user"""
|
||||
user = get_object_or_404(models.User, id=user_id)
|
||||
|
||||
# we can't delete users on other instances
|
||||
if not user.local:
|
||||
raise PermissionDenied
|
||||
|
||||
form = forms.DeleteUserForm(request.POST, instance=user)
|
||||
|
||||
moderator = models.User.objects.get(id=request.user.id)
|
||||
|
|
Loading…
Reference in a new issue