From 168a2488e2bbcbdd5198a4f6d1a75f370365fe68 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 15 Nov 2021 20:59:22 +1100 Subject: [PATCH 01/22] refactor shelf activity on book page - disallow moving from custom shelf to a reading status shelf with shelf_selector - always use shelve_button for moving books from a reading status shelf - redesign shelf information as a list of boxes --- bookwyrm/templates/book/book.html | 21 +++++++++++++++---- .../templates/snippets/shelf_selector.html | 4 ++++ bookwyrm/templatetags/bookwyrm_tags.py | 11 ++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index 36241ee2..a1a73135 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -153,12 +153,25 @@ {# user's relationship to the book #}
+ {% if user_shelfbooks.count > 0 %} +

+ {% trans "You have shelved this edition in:" %} +

+ + {% endif %} {% for shelf in other_edition_shelves %}

{% blocktrans with book_path=shelf.book.local_path shelf_path=shelf.shelf.local_path shelf_name=shelf.shelf.name %}A different edition of this book is on your {{ shelf_name }} shelf.{% endblocktrans %} diff --git a/bookwyrm/templates/snippets/shelf_selector.html b/bookwyrm/templates/snippets/shelf_selector.html index ca5a39f6..ef5bf5bc 100644 --- a/bookwyrm/templates/snippets/shelf_selector.html +++ b/bookwyrm/templates/snippets/shelf_selector.html @@ -1,5 +1,7 @@ {% extends 'components/dropdown.html' %} {% load i18n %} +{% load bookwyrm_tags %} + {% block dropdown-trigger %} {% trans "Move book" %} @@ -7,6 +9,7 @@ {% block dropdown-list %} {% for shelf in user_shelves %} +{% if shelf.identifier|is_shelf_type:"custom" %}

+{% endif %} {% endfor %}
  • {% blocktrans with path=shelf.shelf.local_path shelf_name=shelf.shelf.name %}{{ shelf_name }}{% endblocktrans %} - {% if shelf.shelf.identifier|is_shelf_type:"readthrough" %} - {% include 'snippets/shelve_button/shelve_button.html' %} + {% if shelf.shelf.editable %} +
    + {% include 'snippets/shelf_selector.html' with current=shelf.shelf class="is-small" %} +
    {% else %} -
    - {% include 'snippets/shelf_selector.html' with current=shelf.shelf class="is-small" %} -
    + {% include 'snippets/shelve_button/shelve_button.html' %} {% endif %}
  • {% endfor %} diff --git a/bookwyrm/templates/snippets/shelf_selector.html b/bookwyrm/templates/snippets/shelf_selector.html index ef5bf5bc..e43d8ca1 100644 --- a/bookwyrm/templates/snippets/shelf_selector.html +++ b/bookwyrm/templates/snippets/shelf_selector.html @@ -9,7 +9,7 @@ {% block dropdown-list %} {% for shelf in user_shelves %} -{% if shelf.identifier|is_shelf_type:"custom" %} +{% if shelf.editable %} +{% else%} +{% with button_class="is-fullwidth is-small shelf-option is-radiusless is-white" %} + +{% endwith %} {% endif %} {% endfor %} @@ -30,4 +65,14 @@ + +{% include 'snippets/reading_modals/want_to_read_modal.html' with book=active_shelf.book controls_text="want_to_read" controls_uid=uuid move_from=current.id %} + +{% include 'snippets/reading_modals/start_reading_modal.html' with book=active_shelf.book controls_text="start_reading" controls_uid=uuid move_from=current.id %} + +{% include 'snippets/reading_modals/finish_reading_modal.html' with book=active_shelf.book controls_text="finish_reading" controls_uid=uuid move_from=current.id readthrough=readthrough %} + +{% include 'snippets/reading_modals/progress_update_modal.html' with book=active_shelf.book controls_text="progress_update" controls_uid=uuid move_from=current.id readthrough=readthrough %} + +{% endwith %} {% endblock %} diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py index 54427ffb..a96ccbc0 100644 --- a/bookwyrm/views/reading.py +++ b/bookwyrm/views/reading.py @@ -9,6 +9,7 @@ from django.views import View from django.views.decorators.http import require_POST from bookwyrm import models +from bookwyrm.views.shelf.shelf_actions import unshelve from .status import CreateStatus from .helpers import get_edition, handle_reading_status, is_api_request from .helpers import load_date_in_user_tz_as_utc @@ -85,12 +86,20 @@ class ReadingStatus(View): if request.POST.get("post-status"): # is it a comment? if request.POST.get("content"): + # BUG: there is a problem posting statuses for finishing + # check whether it existed before. return CreateStatus.as_view()(request, "comment") privacy = request.POST.get("privacy") handle_reading_status(request.user, desired_shelf, book, privacy) + if bool(request.POST.get("shelf")): + if current_status_shelfbook is None: + return unshelve(request, referer=referer, book_id=book_id) + return HttpResponse(headers={"forceReload" : "true"}) + if is_api_request(request): return HttpResponse() + return redirect(referer) diff --git a/bookwyrm/views/shelf/shelf_actions.py b/bookwyrm/views/shelf/shelf_actions.py index 702b72c1..8240055e 100644 --- a/bookwyrm/views/shelf/shelf_actions.py +++ b/bookwyrm/views/shelf/shelf_actions.py @@ -1,6 +1,7 @@ """ shelf views """ from django.db import IntegrityError, transaction from django.contrib.auth.decorators import login_required +from django.http.response import HttpResponse from django.shortcuts import get_object_or_404, redirect from django.views.decorators.http import require_POST @@ -91,13 +92,15 @@ def shelve(request): @login_required @require_POST -def unshelve(request): +def unshelve(request, referer=None, book_id=False): """remove a book from a user's shelf""" - book = get_object_or_404(models.Edition, id=request.POST.get("book")) + id = book_id if book_id else request.POST.get("book") + book = get_object_or_404(models.Edition, id=id) shelf_book = get_object_or_404( models.ShelfBook, book=book, shelf__id=request.POST["shelf"] ) shelf_book.raise_not_deletable(request.user) - shelf_book.delete() + if bool(referer): + return HttpResponse(headers={"forceReload" : "true"}) return redirect(request.headers.get("Referer", "/")) From 6951b523652fb26ab9a435475f83da50447fa87e Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sat, 20 Nov 2021 08:18:43 +1100 Subject: [PATCH 05/22] disallow moving to shelf already used --- bookwyrm/templates/snippets/shelf_selector.html | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/bookwyrm/templates/snippets/shelf_selector.html b/bookwyrm/templates/snippets/shelf_selector.html index eca7a1d0..34077dc1 100644 --- a/bookwyrm/templates/snippets/shelf_selector.html +++ b/bookwyrm/templates/snippets/shelf_selector.html @@ -12,13 +12,7 @@ {% with book.id|uuid as uuid %} {% active_shelf book as active_shelf %} {% for shelf in user_shelves %} - {% if shelf.editable %} {% else%} +{% comparison_bool shelf.identifier active_shelf.shelf.identifier as is_current %} {% with button_class="is-fullwidth is-small shelf-option is-radiusless is-white" %}
  • {% blocktrans with path=shelf.shelf.local_path shelf_name=shelf.shelf.name %}{{ shelf_name }}{% endblocktrans %}
    - {% include 'snippets/shelf_selector.html' with current=shelf.shelf class="is-small" %} + {% include 'snippets/shelf_selector.html' with current=shelf.shelf class="is-small" readthrough=readthrough %}
  • {% endfor %} diff --git a/bookwyrm/templates/snippets/shelf_selector.html b/bookwyrm/templates/snippets/shelf_selector.html index 34077dc1..1a2c46d0 100644 --- a/bookwyrm/templates/snippets/shelf_selector.html +++ b/bookwyrm/templates/snippets/shelf_selector.html @@ -11,6 +11,8 @@ {% block dropdown-list %} {% with book.id|uuid as uuid %} {% active_shelf book as active_shelf %} +{% latest_read_through book request.user as readthrough %} + {% for shelf in user_shelves %} {% if shelf.editable %} @@ -67,7 +69,5 @@ {% include 'snippets/reading_modals/finish_reading_modal.html' with book=active_shelf.book controls_text="finish_reading" controls_uid=uuid move_from=current.id readthrough=readthrough %} -{% include 'snippets/reading_modals/progress_update_modal.html' with book=active_shelf.book controls_text="progress_update" controls_uid=uuid move_from=current.id readthrough=readthrough %} - {% endwith %} {% endblock %} From 41862e854cdc95d1d6a1f8d71700d057c43ec661 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sat, 20 Nov 2021 13:57:37 +1100 Subject: [PATCH 09/22] move from reading to editable shelf with logic that actually works --- bookwyrm/views/reading.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py index 8e6ef9a1..c4064d97 100644 --- a/bookwyrm/views/reading.py +++ b/bookwyrm/views/reading.py @@ -96,7 +96,11 @@ class ReadingStatus(View): if bool(request.POST.get("shelf")): # unshelve the existing shelf this_shelf = request.POST.get("shelf") - if int(this_shelf) not in [1,2,3]: + if ( + bool(current_status_shelfbook) and + int(this_shelf) != int(current_status_shelfbook.shelf.id) and + current_status_shelfbook.shelf.identifier != desired_shelf.identifier + ): return unshelve(request, referer=referer, book_id=book_id) # don't try to unshelve a read status shelf: it has already been deleted. return HttpResponse(headers={"forceReload" : "true"}) From af9768a2e31d4652b8afd5da85ec333a15f942ef Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sat, 20 Nov 2021 14:59:59 +1100 Subject: [PATCH 10/22] force page reload when adding status from move button --- bookwyrm/views/status.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bookwyrm/views/status.py b/bookwyrm/views/status.py index 8e487bf9..cd8d2704 100644 --- a/bookwyrm/views/status.py +++ b/bookwyrm/views/status.py @@ -117,12 +117,16 @@ class CreateStatus(View): status.save(created=created) - # update a readthorugh, if needed + # update a readthrough, if needed try: edit_readthrough(request) except Http404: pass + # force page reload if this was triggered from 'move' button + if bool(request.POST.get("shelf")): + return HttpResponse(headers={"forceReload" : "true"}) + if is_api_request(request): return HttpResponse() return redirect("/") @@ -157,6 +161,8 @@ def update_progress(request, book_id): # pylint: disable=unused-argument @require_POST def edit_readthrough(request): """can't use the form because the dates are too finnicky""" + # BUG when triggering finish reading with comments and no previous readthroughs + # this will 404 readthrough = get_object_or_404(models.ReadThrough, id=request.POST.get("id")) readthrough.raise_not_editable(request.user) From 12810d8e341a7d00faca4c6179b3055df3b2a604 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sat, 20 Nov 2021 16:03:46 +1100 Subject: [PATCH 11/22] don't try to update non-existent readthroughs --- bookwyrm/views/reading.py | 2 -- bookwyrm/views/status.py | 9 +++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py index c4064d97..04074b3d 100644 --- a/bookwyrm/views/reading.py +++ b/bookwyrm/views/reading.py @@ -86,8 +86,6 @@ class ReadingStatus(View): if request.POST.get("post-status"): # is it a comment? if request.POST.get("content"): - # BUG: there is a problem posting statuses with comments (doesn't force reload) - # there is a DIFFERENT problem *updating* read statuses/comments return CreateStatus.as_view()(request, "comment") privacy = request.POST.get("privacy") handle_reading_status(request.user, desired_shelf, book, privacy) diff --git a/bookwyrm/views/status.py b/bookwyrm/views/status.py index cd8d2704..8488b21e 100644 --- a/bookwyrm/views/status.py +++ b/bookwyrm/views/status.py @@ -118,10 +118,11 @@ class CreateStatus(View): status.save(created=created) # update a readthrough, if needed - try: - edit_readthrough(request) - except Http404: - pass + if bool(request.POST.get("id")): + try: + edit_readthrough(request) + except Http404: + pass # force page reload if this was triggered from 'move' button if bool(request.POST.get("shelf")): From b273123708c3c2ee4a74d0722edaaba99f0e4eaf Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sat, 20 Nov 2021 16:06:16 +1100 Subject: [PATCH 12/22] code style --- bookwyrm/static/js/status_cache.js | 1 + bookwyrm/templatetags/bookwyrm_tags.py | 6 +++++- bookwyrm/views/reading.py | 13 +++++++------ bookwyrm/views/shelf/shelf_actions.py | 2 +- bookwyrm/views/status.py | 2 +- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/bookwyrm/static/js/status_cache.js b/bookwyrm/static/js/status_cache.js index c59e23ee..49f1c129 100644 --- a/bookwyrm/static/js/status_cache.js +++ b/bookwyrm/static/js/status_cache.js @@ -192,6 +192,7 @@ let StatusCache = new class { .forEach(item => BookWyrm.addRemoveClass(item, "is-hidden", false)); // Remove existing disabled states + // BUG: this affects all shelves, not just shelving status shelves button.querySelectorAll("[data-shelf-dropdown-identifier] button") .forEach(item => item.disabled = false); diff --git a/bookwyrm/templatetags/bookwyrm_tags.py b/bookwyrm/templatetags/bookwyrm_tags.py index 425ecc15..9d84d1ff 100644 --- a/bookwyrm/templatetags/bookwyrm_tags.py +++ b/bookwyrm/templatetags/bookwyrm_tags.py @@ -77,7 +77,11 @@ def related_status(notification): def active_shelf(context, book): """check what shelf a user has a book on, if any""" if hasattr(book, "current_shelves"): - read_shelves = [s for s in book.current_shelves if s.shelf.identifier in models.Shelf.READ_STATUS_IDENTIFIERS] + read_shelves = [ + s + for s in book.current_shelves + if s.shelf.identifier in models.Shelf.READ_STATUS_IDENTIFIERS + ] return read_shelves[0] if len(read_shelves) else {"book": book} shelf = ( diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py index 04074b3d..334235b3 100644 --- a/bookwyrm/views/reading.py +++ b/bookwyrm/views/reading.py @@ -91,17 +91,18 @@ class ReadingStatus(View): handle_reading_status(request.user, desired_shelf, book, privacy) # if the request includes a "shelf" value we are using the 'move' button - if bool(request.POST.get("shelf")): + if bool(request.POST.get("shelf")): # unshelve the existing shelf this_shelf = request.POST.get("shelf") if ( - bool(current_status_shelfbook) and - int(this_shelf) != int(current_status_shelfbook.shelf.id) and - current_status_shelfbook.shelf.identifier != desired_shelf.identifier - ): + bool(current_status_shelfbook) + and int(this_shelf) != int(current_status_shelfbook.shelf.id) + and current_status_shelfbook.shelf.identifier + != desired_shelf.identifier + ): return unshelve(request, referer=referer, book_id=book_id) # don't try to unshelve a read status shelf: it has already been deleted. - return HttpResponse(headers={"forceReload" : "true"}) + return HttpResponse(headers={"forceReload": "true"}) if is_api_request(request): return HttpResponse() diff --git a/bookwyrm/views/shelf/shelf_actions.py b/bookwyrm/views/shelf/shelf_actions.py index 8240055e..f431c1fa 100644 --- a/bookwyrm/views/shelf/shelf_actions.py +++ b/bookwyrm/views/shelf/shelf_actions.py @@ -102,5 +102,5 @@ def unshelve(request, referer=None, book_id=False): shelf_book.raise_not_deletable(request.user) shelf_book.delete() if bool(referer): - return HttpResponse(headers={"forceReload" : "true"}) + return HttpResponse(headers={"forceReload": "true"}) return redirect(request.headers.get("Referer", "/")) diff --git a/bookwyrm/views/status.py b/bookwyrm/views/status.py index 8488b21e..eafe0680 100644 --- a/bookwyrm/views/status.py +++ b/bookwyrm/views/status.py @@ -126,7 +126,7 @@ class CreateStatus(View): # force page reload if this was triggered from 'move' button if bool(request.POST.get("shelf")): - return HttpResponse(headers={"forceReload" : "true"}) + return HttpResponse(headers={"forceReload": "true"}) if is_api_request(request): return HttpResponse() From 4b6f5c9f5179abc3d000d1424edd7c1af39ac51d Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sat, 20 Nov 2021 19:03:57 +1100 Subject: [PATCH 13/22] remove out of date comment --- bookwyrm/views/status.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/bookwyrm/views/status.py b/bookwyrm/views/status.py index eafe0680..588dcf6a 100644 --- a/bookwyrm/views/status.py +++ b/bookwyrm/views/status.py @@ -162,8 +162,6 @@ def update_progress(request, book_id): # pylint: disable=unused-argument @require_POST def edit_readthrough(request): """can't use the form because the dates are too finnicky""" - # BUG when triggering finish reading with comments and no previous readthroughs - # this will 404 readthrough = get_object_or_404(models.ReadThrough, id=request.POST.get("id")) readthrough.raise_not_editable(request.user) From b406a0353301d74cb380411049b67262e4074205 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sat, 20 Nov 2021 19:04:51 +1100 Subject: [PATCH 14/22] don't persist form state in firefox Fixes shelves not being disabled in dropdowns. See https://stackoverflow.com/questions/5985839/bug-with-firefox-disabled-attribute-of-input-not-resetting-when-refreshing --- .../snippets/shelve_button/shelve_button_dropdown_options.html | 2 +- bookwyrm/templates/snippets/toggle/toggle_button.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html index 32319f86..8c1881ce 100644 --- a/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html @@ -32,7 +32,7 @@ {% elif shelf.editable %} -
    + {% csrf_token %} + +
    +{% endfor %} +{% else %} + + +{% endif %} {% include 'snippets/reading_modals/want_to_read_modal.html' with book=active_shelf.book controls_text="want_to_read" controls_uid=uuid move_from=current.id %} From b91915d31680b71864ba14cc686442fb58a2c9c1 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Thu, 25 Nov 2021 08:20:34 +1100 Subject: [PATCH 18/22] change shelf var for shelf_selector in book view --- bookwyrm/templates/book/book.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index 1eb08001..713e7abe 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -162,7 +162,7 @@
  • {% blocktrans with path=shelf.shelf.local_path shelf_name=shelf.shelf.name %}{{ shelf_name }}{% endblocktrans %}
    - {% include 'snippets/shelf_selector.html' with current=shelf.shelf class="is-small" readthrough=readthrough %} + {% include 'snippets/shelf_selector.html' with shelf=shelf.shelf class="is-small" readthrough=readthrough %}
  • {% endfor %} From 5b67226571d85d281e3ccedc2710084ffceb2201 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Thu, 25 Nov 2021 19:12:03 +1100 Subject: [PATCH 19/22] forceReload prevents ajax submission ...instead of weird hacky workarounds forcing refreshes later. --- bookwyrm/static/js/status_cache.js | 8 +------- bookwyrm/views/reading.py | 2 -- bookwyrm/views/shelf/shelf_actions.py | 2 -- bookwyrm/views/status.py | 4 ---- 4 files changed, 1 insertion(+), 15 deletions(-) diff --git a/bookwyrm/static/js/status_cache.js b/bookwyrm/static/js/status_cache.js index f179aa7d..1ec72b3c 100644 --- a/bookwyrm/static/js/status_cache.js +++ b/bookwyrm/static/js/status_cache.js @@ -74,7 +74,7 @@ let StatusCache = new class { // This allows the form to submit in the old fashioned way if there's a problem - if (!trigger || !form) { + if (!trigger || !form || response.headers.get("forceReload")) { return; } @@ -90,12 +90,6 @@ let StatusCache = new class { trigger.removeAttribute('disabled'); }) .then(response => { - if (response.headers.get("forceReload")) { - BookWyrm.addRemoveClass(form, 'is-processing', true); - trigger.setAttribute('disabled', null); - - return location.reload(); - } if (!response.ok) { throw new Error(); diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py index 75a45f24..a91fa8e7 100644 --- a/bookwyrm/views/reading.py +++ b/bookwyrm/views/reading.py @@ -102,8 +102,6 @@ class ReadingStatus(View): != desired_shelf.identifier ): return unshelve(request, referer=referer, book_id=book_id) - # don't try to unshelve a read status shelf: it has already been deleted. - return HttpResponse(headers={"forceReload": "true"}) if is_api_request(request): return HttpResponse() diff --git a/bookwyrm/views/shelf/shelf_actions.py b/bookwyrm/views/shelf/shelf_actions.py index 77053f53..3fff92a6 100644 --- a/bookwyrm/views/shelf/shelf_actions.py +++ b/bookwyrm/views/shelf/shelf_actions.py @@ -101,6 +101,4 @@ def unshelve(request, referer=None, book_id=False): ) shelf_book.raise_not_deletable(request.user) shelf_book.delete() - if bool(referer): - return HttpResponse(headers={"forceReload": "true"}) return redirect(request.headers.get("Referer", "/")) diff --git a/bookwyrm/views/status.py b/bookwyrm/views/status.py index 144408b5..bb69d30c 100644 --- a/bookwyrm/views/status.py +++ b/bookwyrm/views/status.py @@ -125,10 +125,6 @@ class CreateStatus(View): except Http404: pass - # force page reload if this was triggered from 'move' button - if bool(request.POST.get("shelf")): - return HttpResponse(headers={"forceReload": "true"}) - if is_api_request(request): return HttpResponse() return redirect("/") From 951eb43aa657d9ced537b078bf14286520b18a66 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Fri, 26 Nov 2021 17:16:26 +1100 Subject: [PATCH 20/22] bypass ajax for shelf_selector statuses --- bookwyrm/static/js/status_cache.js | 3 +-- .../snippets/reading_modals/finish_reading_modal.html | 2 +- .../snippets/reading_modals/start_reading_modal.html | 2 +- .../snippets/reading_modals/want_to_read_modal.html | 2 +- bookwyrm/templates/snippets/shelf_selector.html | 6 +++--- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/bookwyrm/static/js/status_cache.js b/bookwyrm/static/js/status_cache.js index 1ec72b3c..418b7dee 100644 --- a/bookwyrm/static/js/status_cache.js +++ b/bookwyrm/static/js/status_cache.js @@ -74,7 +74,7 @@ let StatusCache = new class { // This allows the form to submit in the old fashioned way if there's a problem - if (!trigger || !form || response.headers.get("forceReload")) { + if (!trigger || !form) { return; } @@ -90,7 +90,6 @@ let StatusCache = new class { trigger.removeAttribute('disabled'); }) .then(response => { - if (!response.ok) { throw new Error(); } diff --git a/bookwyrm/templates/snippets/reading_modals/finish_reading_modal.html b/bookwyrm/templates/snippets/reading_modals/finish_reading_modal.html index 79542b29..a35ed9e0 100644 --- a/bookwyrm/templates/snippets/reading_modals/finish_reading_modal.html +++ b/bookwyrm/templates/snippets/reading_modals/finish_reading_modal.html @@ -9,7 +9,7 @@ Finish "{{ book_title }}" {% endblock %} {% block modal-form-open %} -
    + {% csrf_token %} diff --git a/bookwyrm/templates/snippets/reading_modals/start_reading_modal.html b/bookwyrm/templates/snippets/reading_modals/start_reading_modal.html index 03ebd900..423f77eb 100644 --- a/bookwyrm/templates/snippets/reading_modals/start_reading_modal.html +++ b/bookwyrm/templates/snippets/reading_modals/start_reading_modal.html @@ -9,7 +9,7 @@ Start "{{ book_title }}" {% endblock %} {% block modal-form-open %} - + {% csrf_token %} diff --git a/bookwyrm/templates/snippets/reading_modals/want_to_read_modal.html b/bookwyrm/templates/snippets/reading_modals/want_to_read_modal.html index 2fc2a012..2fb976bf 100644 --- a/bookwyrm/templates/snippets/reading_modals/want_to_read_modal.html +++ b/bookwyrm/templates/snippets/reading_modals/want_to_read_modal.html @@ -9,7 +9,7 @@ Want to Read "{{ book_title }}" {% endblock %} {% block modal-form-open %} - + {% csrf_token %} diff --git a/bookwyrm/templates/snippets/shelf_selector.html b/bookwyrm/templates/snippets/shelf_selector.html index 663bd563..4b32f5a8 100644 --- a/bookwyrm/templates/snippets/shelf_selector.html +++ b/bookwyrm/templates/snippets/shelf_selector.html @@ -78,11 +78,11 @@ {% endif %} -{% include 'snippets/reading_modals/want_to_read_modal.html' with book=active_shelf.book controls_text="want_to_read" controls_uid=uuid move_from=current.id %} +{% include 'snippets/reading_modals/want_to_read_modal.html' with book=active_shelf.book controls_text="want_to_read" controls_uid=uuid move_from=current.id refresh=True %} -{% include 'snippets/reading_modals/start_reading_modal.html' with book=active_shelf.book controls_text="start_reading" controls_uid=uuid move_from=current.id %} +{% include 'snippets/reading_modals/start_reading_modal.html' with book=active_shelf.book controls_text="start_reading" controls_uid=uuid move_from=current.id refresh=True %} -{% include 'snippets/reading_modals/finish_reading_modal.html' with book=active_shelf.book controls_text="finish_reading" controls_uid=uuid move_from=current.id readthrough=readthrough %} +{% include 'snippets/reading_modals/finish_reading_modal.html' with book=active_shelf.book controls_text="finish_reading" controls_uid=uuid move_from=current.id readthrough=readthrough refresh=True %} {% endwith %} {% endblock %} From a5efc798f8e7a897badc301736443f5f7087affb Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Fri, 26 Nov 2021 17:30:27 +1100 Subject: [PATCH 21/22] clean up old vars --- bookwyrm/views/shelf/shelf_actions.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bookwyrm/views/shelf/shelf_actions.py b/bookwyrm/views/shelf/shelf_actions.py index 3fff92a6..5e7e6c0c 100644 --- a/bookwyrm/views/shelf/shelf_actions.py +++ b/bookwyrm/views/shelf/shelf_actions.py @@ -1,7 +1,6 @@ """ shelf views """ from django.db import IntegrityError, transaction from django.contrib.auth.decorators import login_required -from django.http.response import HttpResponse from django.shortcuts import get_object_or_404, redirect from django.views.decorators.http import require_POST @@ -92,7 +91,7 @@ def shelve(request): @login_required @require_POST -def unshelve(request, referer=None, book_id=False): +def unshelve(request, book_id=False): """remove a book from a user's shelf""" identity = book_id if book_id else request.POST.get("book") book = get_object_or_404(models.Edition, id=identity) From 1a37903583235ff2b4d0b98767ef3e91ac3ffeb3 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Fri, 26 Nov 2021 17:39:35 +1100 Subject: [PATCH 22/22] remove unnecessary function call arg --- bookwyrm/views/reading.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py index a91fa8e7..35847558 100644 --- a/bookwyrm/views/reading.py +++ b/bookwyrm/views/reading.py @@ -101,7 +101,7 @@ class ReadingStatus(View): and current_status_shelfbook.shelf.identifier != desired_shelf.identifier ): - return unshelve(request, referer=referer, book_id=book_id) + return unshelve(request, book_id=book_id) if is_api_request(request): return HttpResponse()