forked from mirrors/bookwyrm
Use url names in redirects
This commit is contained in:
parent
92de48afd4
commit
28d40e9914
6 changed files with 11 additions and 9 deletions
|
@ -56,7 +56,7 @@ urlpatterns = [
|
|||
views.ConfirmEmailCode.as_view(),
|
||||
name="confirm-email-code",
|
||||
),
|
||||
re_path(r"resend-link", views.resend_link, name="resend-link"),
|
||||
re_path(r"^resend-link/?$", views.resend_link, name="resend-link"),
|
||||
re_path(r"^logout/?$", views.Logout.as_view(), name="logout"),
|
||||
re_path(
|
||||
r"^password-reset/?$",
|
||||
|
|
|
@ -51,7 +51,7 @@ class ManageInvites(View):
|
|||
"""creates an invite database entry"""
|
||||
form = forms.CreateInviteForm(request.POST)
|
||||
if not form.is_valid():
|
||||
return HttpResponseBadRequest("ERRORS : %s" % (form.errors,))
|
||||
return HttpResponseBadRequest(f"ERRORS: {form.errors}")
|
||||
|
||||
invite = form.save(commit=False)
|
||||
invite.user = request.user
|
||||
|
@ -98,6 +98,7 @@ class ManageInviteRequests(View):
|
|||
"invite__times_used",
|
||||
"invite__invitees__created_date",
|
||||
]
|
||||
# pylint: disable=consider-using-f-string
|
||||
if not sort in sort_fields + ["-{:s}".format(f) for f in sort_fields]:
|
||||
sort = "-created_date"
|
||||
|
||||
|
@ -149,6 +150,7 @@ class ManageInviteRequests(View):
|
|||
)
|
||||
invite_request.save()
|
||||
emailing.invite_email(invite_request)
|
||||
# pylint: disable=consider-using-f-string
|
||||
return redirect(
|
||||
"{:s}?{:s}".format(
|
||||
reverse("settings-invite-requests"), urlencode(request.GET.dict())
|
||||
|
|
|
@ -24,7 +24,7 @@ class Block(View):
|
|||
models.UserBlocks.objects.create(
|
||||
user_subject=request.user, user_object=to_block
|
||||
)
|
||||
return redirect("/preferences/block")
|
||||
return redirect("prefs-block")
|
||||
|
||||
|
||||
@require_POST
|
||||
|
@ -40,4 +40,4 @@ def unblock(request, user_id):
|
|||
except models.UserBlocks.DoesNotExist:
|
||||
return HttpResponseNotFound()
|
||||
block.delete()
|
||||
return redirect("/preferences/block")
|
||||
return redirect("prefs-block")
|
||||
|
|
|
@ -34,9 +34,9 @@ class EditUser(View):
|
|||
data = {"form": form, "user": request.user}
|
||||
return TemplateResponse(request, "preferences/edit_user.html", data)
|
||||
|
||||
user = save_user_form(form)
|
||||
save_user_form(form)
|
||||
|
||||
return redirect(user.local_path)
|
||||
return redirect("user-feed", request.user.localname)
|
||||
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
|
|
|
@ -29,4 +29,4 @@ class Notifications(View):
|
|||
def post(self, request):
|
||||
"""permanently delete notification for user"""
|
||||
request.user.notification_set.filter(read=True).delete()
|
||||
return redirect("/notifications")
|
||||
return redirect("notifications")
|
||||
|
|
|
@ -97,9 +97,9 @@ class ChangePassword(View):
|
|||
confirm_password = request.POST.get("confirm-password")
|
||||
|
||||
if new_password != confirm_password:
|
||||
return redirect("preferences/password")
|
||||
return redirect("prefs-password")
|
||||
|
||||
request.user.set_password(new_password)
|
||||
request.user.save(broadcast=False, update_fields=["password"])
|
||||
login(request, request.user)
|
||||
return redirect(request.user.local_path)
|
||||
return redirect("user-feed", request.user.localname)
|
||||
|
|
Loading…
Reference in a new issue