Merge branch 'main' into fwalloe-patch-1

This commit is contained in:
Fredrik Walløe 2023-04-04 12:15:52 +02:00 committed by GitHub
commit ac17876cb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View file

@ -12,7 +12,7 @@ from django.core.exceptions import ImproperlyConfigured
env = Env() env = Env()
env.read_env() env.read_env()
DOMAIN = env("DOMAIN") DOMAIN = env("DOMAIN")
VERSION = "0.6.0" VERSION = "0.6.1"
RELEASE_API = env( RELEASE_API = env(
"RELEASE_API", "RELEASE_API",

View file

@ -8,6 +8,7 @@ from django.views import View
from django.views.decorators.http import require_POST from django.views.decorators.http import require_POST
from bookwyrm import models from bookwyrm import models
from bookwyrm.views.helpers import redirect_to_referer
from bookwyrm.settings import PAGE_LENGTH from bookwyrm.settings import PAGE_LENGTH
@ -57,7 +58,7 @@ class ImportList(View):
"""Mark an import as complete""" """Mark an import as complete"""
import_job = get_object_or_404(models.ImportJob, id=import_id) import_job = get_object_or_404(models.ImportJob, id=import_id)
import_job.stop_job() import_job.stop_job()
return redirect("settings-imports") return redirect_to_referer(request, "settings-imports")
@require_POST @require_POST

View file

@ -8,6 +8,7 @@ from django.utils.decorators import method_decorator
from django.views import View from django.views import View
from bookwyrm import forms, models from bookwyrm import forms, models
from bookwyrm.views.helpers import redirect_to_referer
from bookwyrm.settings import PAGE_LENGTH from bookwyrm.settings import PAGE_LENGTH
@ -84,26 +85,26 @@ class ReportAdmin(View):
@login_required @login_required
@permission_required("bookwyrm.moderate_user") @permission_required("bookwyrm.moderate_user")
def suspend_user(_, user_id): def suspend_user(request, user_id):
"""mark an account as inactive""" """mark an account as inactive"""
user = get_object_or_404(models.User, id=user_id) user = get_object_or_404(models.User, id=user_id)
user.is_active = False user.is_active = False
user.deactivation_reason = "moderator_suspension" user.deactivation_reason = "moderator_suspension"
# this isn't a full deletion, so we don't want to tell the world # this isn't a full deletion, so we don't want to tell the world
user.save(broadcast=False) user.save(broadcast=False)
return redirect("settings-user", user.id) return redirect_to_referer(request, "settings-user", user.id)
@login_required @login_required
@permission_required("bookwyrm.moderate_user") @permission_required("bookwyrm.moderate_user")
def unsuspend_user(_, user_id): def unsuspend_user(request, user_id):
"""mark an account as inactive""" """mark an account as inactive"""
user = get_object_or_404(models.User, id=user_id) user = get_object_or_404(models.User, id=user_id)
user.is_active = True user.is_active = True
user.deactivation_reason = None user.deactivation_reason = None
# this isn't a full deletion, so we don't want to tell the world # this isn't a full deletion, so we don't want to tell the world
user.save(broadcast=False) user.save(broadcast=False)
return redirect("settings-user", user.id) return redirect_to_referer(request, "settings-user", user.id)
@login_required @login_required
@ -123,7 +124,7 @@ def moderator_delete_user(request, user_id):
if form.is_valid() and moderator.check_password(form.cleaned_data["password"]): if form.is_valid() and moderator.check_password(form.cleaned_data["password"]):
user.deactivation_reason = "moderator_deletion" user.deactivation_reason = "moderator_deletion"
user.delete() user.delete()
return redirect("settings-user", user.id) return redirect_to_referer(request, "settings-user", user.id)
form.errors["password"] = ["Invalid password"] form.errors["password"] = ["Invalid password"]