Merge pull request #1461 from bookwyrm-social/views-init

Adds init file to admin views dir
This commit is contained in:
Mouse Reeve 2021-09-27 10:37:23 -07:00 committed by GitHub
commit eb34bb2d93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 17 additions and 12 deletions

View file

@ -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/?$",

View file

View file

@ -31,6 +31,7 @@ class Announcements(View):
"end_date",
"active",
]
# pylint: disable=consider-using-f-string
if sort in sort_fields + ["-{:s}".format(f) for f in sort_fields]:
announcements = announcements.order_by(sort)
data = {

View file

@ -28,6 +28,7 @@ class Federation(View):
sort = request.GET.get("sort")
sort_fields = ["created_date", "application_type", "server_name"]
# pylint: disable=consider-using-f-string
if not sort in sort_fields + ["-{:s}".format(f) for f in sort_fields]:
sort = "-created_date"
servers = servers.order_by(sort)

View file

@ -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())

View file

@ -41,9 +41,9 @@ def email_preview(request):
"""for development, renders and example email template"""
template = request.GET.get("email")
data = emailing.email_data()
data["subject_path"] = "email/{}/subject.html".format(template)
data["html_content_path"] = "email/{}/html_content.html".format(template)
data["text_content_path"] = "email/{}/text_content.html".format(template)
data["subject_path"] = f"email/{template}/subject.html"
data["html_content_path"] = f"email/{template}/html_content.html"
data["text_content_path"] = f"email/{template}/text_content.html"
data["reset_link"] = "https://example.com/link"
data["invite_link"] = "https://example.com/link"
data["confirmation_link"] = "https://example.com/link"

View file

@ -47,6 +47,7 @@ class UserAdminList(View):
"federated_server__server_name",
"is_active",
]
# pylint: disable=consider-using-f-string
if sort in sort_fields + ["-{:s}".format(f) for f in sort_fields]:
users = users.order_by(sort)

View file

@ -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")

View file

@ -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

View file

@ -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")

View file

@ -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)