From e6ae5005698dc02c0d6221152c8853f9e15edc4f Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 27 Sep 2021 15:57:22 -0700 Subject: [PATCH] Fixes syntax problem on http raises --- bookwyrm/forms.py | 2 +- bookwyrm/models/status.py | 3 +-- bookwyrm/urls.py | 2 +- bookwyrm/views/admin/reports.py | 2 +- bookwyrm/views/books.py | 2 +- bookwyrm/views/import_data.py | 2 +- bookwyrm/views/password.py | 4 ++-- bookwyrm/views/register.py | 4 ++-- 8 files changed, 10 insertions(+), 11 deletions(-) diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index 23063ff7c..b9b93694c 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -228,7 +228,7 @@ class ExpiryWidget(widgets.Select): elif selected_string == "forever": return None else: - return selected_string # "This will raise + return selected_string # This will raise return timezone.now() + interval diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index e4f28e000..b62036788 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -193,8 +193,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): # first, the standard raise super().raise_not_editable(viewer) if isinstance(self, (GeneratedNote, ReviewRating)): - raise PermissionDenied - + raise PermissionDenied() class GeneratedNote(Status): diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index f55051812..7d9bd8da3 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -276,7 +276,7 @@ urlpatterns = [ # User books re_path(rf"{USER_PATH}/books/?$", views.Shelf.as_view(), name="user-shelves"), re_path( - rf"^{USER_PATH}/(helf|books)/(?P[\w-]+)(.json)?/?$", + rf"^{USER_PATH}/(shelf|books)/(?P[\w-]+)(.json)?/?$", views.Shelf.as_view(), name="shelf", ), diff --git a/bookwyrm/views/admin/reports.py b/bookwyrm/views/admin/reports.py index 72b7f4db9..23bb6fa3d 100644 --- a/bookwyrm/views/admin/reports.py +++ b/bookwyrm/views/admin/reports.py @@ -105,7 +105,7 @@ def moderator_delete_user(request, user_id): # we can't delete users on other instances if not user.local: - raise PermissionDenied + raise PermissionDenied() form = forms.DeleteUserForm(request.POST, instance=user) diff --git a/bookwyrm/views/books.py b/bookwyrm/views/books.py index 6ab938db2..e2878aca7 100644 --- a/bookwyrm/views/books.py +++ b/bookwyrm/views/books.py @@ -50,7 +50,7 @@ class Book(View): ) if not book or not book.parent_work: - raise Http404 + raise Http404() # all reviews for all editions of the book reviews = privacy_filter( diff --git a/bookwyrm/views/import_data.py b/bookwyrm/views/import_data.py index 2232e39c2..fe54c39a9 100644 --- a/bookwyrm/views/import_data.py +++ b/bookwyrm/views/import_data.py @@ -80,7 +80,7 @@ class ImportStatus(View): """status of an import job""" job = get_object_or_404(models.ImportJob, id=job_id) if job.user != request.user: - raise PermissionDenied + raise PermissionDenied() try: task = app.AsyncResult(job.task_id) diff --git a/bookwyrm/views/password.py b/bookwyrm/views/password.py index 4f0bd50dc..b9cb99ded 100644 --- a/bookwyrm/views/password.py +++ b/bookwyrm/views/password.py @@ -54,9 +54,9 @@ class PasswordReset(View): try: reset_code = models.PasswordReset.objects.get(code=code) if not reset_code.valid(): - raise PermissionDenied + raise PermissionDenied() except models.PasswordReset.DoesNotExist: - raise PermissionDenied + raise PermissionDenied() return TemplateResponse(request, "password_reset.html", {"code": code}) diff --git a/bookwyrm/views/register.py b/bookwyrm/views/register.py index bf927e682..dd8249203 100644 --- a/bookwyrm/views/register.py +++ b/bookwyrm/views/register.py @@ -29,11 +29,11 @@ class Register(View): invite_code = request.POST.get("invite_code") if not invite_code: - raise PermissionDenied + raise PermissionDenied() invite = get_object_or_404(models.SiteInvite, code=invite_code) if not invite.valid(): - raise PermissionDenied + raise PermissionDenied() else: invite = None