mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-25 01:20:35 +00:00
Merge pull request #1461 from bookwyrm-social/views-init
Adds init file to admin views dir
This commit is contained in:
commit
eb34bb2d93
11 changed files with 17 additions and 12 deletions
|
@ -56,7 +56,7 @@ urlpatterns = [
|
||||||
views.ConfirmEmailCode.as_view(),
|
views.ConfirmEmailCode.as_view(),
|
||||||
name="confirm-email-code",
|
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"^logout/?$", views.Logout.as_view(), name="logout"),
|
||||||
re_path(
|
re_path(
|
||||||
r"^password-reset/?$",
|
r"^password-reset/?$",
|
||||||
|
|
0
bookwyrm/views/admin/__init__.py
Normal file
0
bookwyrm/views/admin/__init__.py
Normal file
|
@ -31,6 +31,7 @@ class Announcements(View):
|
||||||
"end_date",
|
"end_date",
|
||||||
"active",
|
"active",
|
||||||
]
|
]
|
||||||
|
# pylint: disable=consider-using-f-string
|
||||||
if sort in sort_fields + ["-{:s}".format(f) for f in sort_fields]:
|
if sort in sort_fields + ["-{:s}".format(f) for f in sort_fields]:
|
||||||
announcements = announcements.order_by(sort)
|
announcements = announcements.order_by(sort)
|
||||||
data = {
|
data = {
|
||||||
|
|
|
@ -28,6 +28,7 @@ class Federation(View):
|
||||||
|
|
||||||
sort = request.GET.get("sort")
|
sort = request.GET.get("sort")
|
||||||
sort_fields = ["created_date", "application_type", "server_name"]
|
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]:
|
if not sort in sort_fields + ["-{:s}".format(f) for f in sort_fields]:
|
||||||
sort = "-created_date"
|
sort = "-created_date"
|
||||||
servers = servers.order_by(sort)
|
servers = servers.order_by(sort)
|
||||||
|
|
|
@ -51,7 +51,7 @@ class ManageInvites(View):
|
||||||
"""creates an invite database entry"""
|
"""creates an invite database entry"""
|
||||||
form = forms.CreateInviteForm(request.POST)
|
form = forms.CreateInviteForm(request.POST)
|
||||||
if not form.is_valid():
|
if not form.is_valid():
|
||||||
return HttpResponseBadRequest("ERRORS : %s" % (form.errors,))
|
return HttpResponseBadRequest(f"ERRORS: {form.errors}")
|
||||||
|
|
||||||
invite = form.save(commit=False)
|
invite = form.save(commit=False)
|
||||||
invite.user = request.user
|
invite.user = request.user
|
||||||
|
@ -98,6 +98,7 @@ class ManageInviteRequests(View):
|
||||||
"invite__times_used",
|
"invite__times_used",
|
||||||
"invite__invitees__created_date",
|
"invite__invitees__created_date",
|
||||||
]
|
]
|
||||||
|
# pylint: disable=consider-using-f-string
|
||||||
if not sort in sort_fields + ["-{:s}".format(f) for f in sort_fields]:
|
if not sort in sort_fields + ["-{:s}".format(f) for f in sort_fields]:
|
||||||
sort = "-created_date"
|
sort = "-created_date"
|
||||||
|
|
||||||
|
@ -149,6 +150,7 @@ class ManageInviteRequests(View):
|
||||||
)
|
)
|
||||||
invite_request.save()
|
invite_request.save()
|
||||||
emailing.invite_email(invite_request)
|
emailing.invite_email(invite_request)
|
||||||
|
# pylint: disable=consider-using-f-string
|
||||||
return redirect(
|
return redirect(
|
||||||
"{:s}?{:s}".format(
|
"{:s}?{:s}".format(
|
||||||
reverse("settings-invite-requests"), urlencode(request.GET.dict())
|
reverse("settings-invite-requests"), urlencode(request.GET.dict())
|
||||||
|
|
|
@ -41,9 +41,9 @@ def email_preview(request):
|
||||||
"""for development, renders and example email template"""
|
"""for development, renders and example email template"""
|
||||||
template = request.GET.get("email")
|
template = request.GET.get("email")
|
||||||
data = emailing.email_data()
|
data = emailing.email_data()
|
||||||
data["subject_path"] = "email/{}/subject.html".format(template)
|
data["subject_path"] = f"email/{template}/subject.html"
|
||||||
data["html_content_path"] = "email/{}/html_content.html".format(template)
|
data["html_content_path"] = f"email/{template}/html_content.html"
|
||||||
data["text_content_path"] = "email/{}/text_content.html".format(template)
|
data["text_content_path"] = f"email/{template}/text_content.html"
|
||||||
data["reset_link"] = "https://example.com/link"
|
data["reset_link"] = "https://example.com/link"
|
||||||
data["invite_link"] = "https://example.com/link"
|
data["invite_link"] = "https://example.com/link"
|
||||||
data["confirmation_link"] = "https://example.com/link"
|
data["confirmation_link"] = "https://example.com/link"
|
||||||
|
|
|
@ -47,6 +47,7 @@ class UserAdminList(View):
|
||||||
"federated_server__server_name",
|
"federated_server__server_name",
|
||||||
"is_active",
|
"is_active",
|
||||||
]
|
]
|
||||||
|
# pylint: disable=consider-using-f-string
|
||||||
if sort in sort_fields + ["-{:s}".format(f) for f in sort_fields]:
|
if sort in sort_fields + ["-{:s}".format(f) for f in sort_fields]:
|
||||||
users = users.order_by(sort)
|
users = users.order_by(sort)
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ class Block(View):
|
||||||
models.UserBlocks.objects.create(
|
models.UserBlocks.objects.create(
|
||||||
user_subject=request.user, user_object=to_block
|
user_subject=request.user, user_object=to_block
|
||||||
)
|
)
|
||||||
return redirect("/preferences/block")
|
return redirect("prefs-block")
|
||||||
|
|
||||||
|
|
||||||
@require_POST
|
@require_POST
|
||||||
|
@ -40,4 +40,4 @@ def unblock(request, user_id):
|
||||||
except models.UserBlocks.DoesNotExist:
|
except models.UserBlocks.DoesNotExist:
|
||||||
return HttpResponseNotFound()
|
return HttpResponseNotFound()
|
||||||
block.delete()
|
block.delete()
|
||||||
return redirect("/preferences/block")
|
return redirect("prefs-block")
|
||||||
|
|
|
@ -34,9 +34,9 @@ class EditUser(View):
|
||||||
data = {"form": form, "user": request.user}
|
data = {"form": form, "user": request.user}
|
||||||
return TemplateResponse(request, "preferences/edit_user.html", data)
|
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
|
# pylint: disable=no-self-use
|
||||||
|
|
|
@ -29,4 +29,4 @@ class Notifications(View):
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
"""permanently delete notification for user"""
|
"""permanently delete notification for user"""
|
||||||
request.user.notification_set.filter(read=True).delete()
|
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")
|
confirm_password = request.POST.get("confirm-password")
|
||||||
|
|
||||||
if new_password != confirm_password:
|
if new_password != confirm_password:
|
||||||
return redirect("preferences/password")
|
return redirect("prefs-password")
|
||||||
|
|
||||||
request.user.set_password(new_password)
|
request.user.set_password(new_password)
|
||||||
request.user.save(broadcast=False, update_fields=["password"])
|
request.user.save(broadcast=False, update_fields=["password"])
|
||||||
login(request, request.user)
|
login(request, request.user)
|
||||||
return redirect(request.user.local_path)
|
return redirect("user-feed", request.user.localname)
|
||||||
|
|
Loading…
Reference in a new issue