mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 19:41:11 +00:00
feat: button in admin view to manually activate pending user
This commit is contained in:
parent
48ac90a984
commit
07f4300176
5 changed files with 28 additions and 3 deletions
|
@ -15,6 +15,12 @@
|
|||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if not user.is_active and user.deactivation_reason == "pending" %}
|
||||
<form name="suspend" method="post" action="{% url 'settings-activate-user' user.id %}" class="mr-1">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="button is-success is-light">{% trans "Activate user" %}</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% if user.is_active or user.deactivation_reason == "pending" %}
|
||||
<form name="suspend" method="post" action="{% url 'settings-report-suspend' user.id %}" class="mr-1">
|
||||
{% csrf_token %}
|
||||
|
|
|
@ -145,6 +145,11 @@ urlpatterns = [
|
|||
views.UserAdmin.as_view(),
|
||||
name="settings-user",
|
||||
),
|
||||
re_path(
|
||||
r"^settings/users/(?P<user>\d+)/activate/?$",
|
||||
views.ActivateUserAdmin.as_view(),
|
||||
name="settings-activate-user",
|
||||
),
|
||||
re_path(
|
||||
r"^settings/federation/(?P<status>(federated|blocked))?/?$",
|
||||
views.Federation.as_view(),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
""" defining regexes for regularly used concepts """
|
||||
|
||||
DOMAIN = r"[\w_\-\.]+\.[a-z\-]{2,}"
|
||||
DOMAIN = r"(?:localhost:[0-9]{4,}|[\w_\-\.]+\.[a-z\-]{2,})"
|
||||
LOCALNAME = r"@?[a-zA-Z_\-\.0-9]+"
|
||||
STRICT_LOCALNAME = r"@[a-zA-Z_\-\.0-9]+"
|
||||
USERNAME = rf"{LOCALNAME}(@{DOMAIN})?"
|
||||
|
|
|
@ -31,7 +31,7 @@ from .admin.reports import (
|
|||
)
|
||||
from .admin.site import Site, Registration, RegistrationLimited
|
||||
from .admin.themes import Themes, delete_theme
|
||||
from .admin.user_admin import UserAdmin, UserAdminList
|
||||
from .admin.user_admin import UserAdmin, UserAdminList, ActivateUserAdmin
|
||||
|
||||
# user preferences
|
||||
from .preferences.change_password import ChangePassword
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
""" manage user """
|
||||
from django.contrib.auth.decorators import login_required, permission_required
|
||||
from django.core.paginator import Paginator
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.template.response import TemplateResponse
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views import View
|
||||
|
@ -95,3 +95,17 @@ class UserAdmin(View):
|
|||
form.save(request)
|
||||
data = {"user": user, "group_form": form}
|
||||
return TemplateResponse(request, "settings/users/user.html", data)
|
||||
|
||||
@method_decorator(login_required, name="dispatch")
|
||||
@method_decorator(
|
||||
permission_required("bookwyrm.moderate_user", raise_exception=True),
|
||||
name="dispatch",
|
||||
)
|
||||
class ActivateUserAdmin(View):
|
||||
"""activate a user manually"""
|
||||
|
||||
def post(self, request, user):
|
||||
"""activate user"""
|
||||
user = get_object_or_404(models.User, id=user)
|
||||
user.reactivate()
|
||||
return redirect("settings-user", user.id)
|
||||
|
|
Loading…
Reference in a new issue