mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-27 03:51:08 +00:00
Fixes redirects in fallback post modal
This commit is contained in:
parent
55b674258d
commit
a2811b6c1b
1 changed files with 7 additions and 3 deletions
|
@ -31,6 +31,7 @@ class ReadingStatus(View):
|
||||||
}.get(status)
|
}.get(status)
|
||||||
if not template:
|
if not template:
|
||||||
return HttpResponseNotFound()
|
return HttpResponseNotFound()
|
||||||
|
# redirect if we're already on this shelf
|
||||||
return TemplateResponse(request, f"reading_progress/{template}", {"book": book})
|
return TemplateResponse(request, f"reading_progress/{template}", {"book": book})
|
||||||
|
|
||||||
def post(self, request, status, book_id):
|
def post(self, request, status, book_id):
|
||||||
|
@ -58,11 +59,15 @@ class ReadingStatus(View):
|
||||||
)
|
)
|
||||||
.first()
|
.first()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
referer = request.headers.get("Referer", "/")
|
||||||
|
if "reading-status" in referer:
|
||||||
|
referer = "/"
|
||||||
if current_status_shelfbook is not None:
|
if current_status_shelfbook is not None:
|
||||||
if current_status_shelfbook.shelf.identifier != desired_shelf.identifier:
|
if current_status_shelfbook.shelf.identifier != desired_shelf.identifier:
|
||||||
current_status_shelfbook.delete()
|
current_status_shelfbook.delete()
|
||||||
else: # It already was on the shelf
|
else: # It already was on the shelf
|
||||||
return redirect(request.headers.get("Referer", "/"))
|
return redirect(referer)
|
||||||
|
|
||||||
models.ShelfBook.objects.create(
|
models.ShelfBook.objects.create(
|
||||||
book=book, shelf=desired_shelf, user=request.user
|
book=book, shelf=desired_shelf, user=request.user
|
||||||
|
@ -87,8 +92,7 @@ class ReadingStatus(View):
|
||||||
else:
|
else:
|
||||||
privacy = request.POST.get("privacy")
|
privacy = request.POST.get("privacy")
|
||||||
handle_reading_status(request.user, desired_shelf, book, privacy)
|
handle_reading_status(request.user, desired_shelf, book, privacy)
|
||||||
|
return redirect(referer)
|
||||||
return redirect(request.headers.get("Referer", "/"))
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
|
Loading…
Reference in a new issue