Merge pull request #1362 from bookwyrm-social/fallback-modal
Fallback modal
This commit is contained in:
commit
fb0989e902
|
@ -14,7 +14,11 @@
|
||||||
<h2 class="modal-card-title is-flex-shrink-1" id="modal_card_title_{{ controls_text }}_{{ controls_uid }}">
|
<h2 class="modal-card-title is-flex-shrink-1" id="modal_card_title_{{ controls_text }}_{{ controls_uid }}">
|
||||||
{% block modal-title %}{% endblock %}
|
{% block modal-title %}{% endblock %}
|
||||||
</h2>
|
</h2>
|
||||||
|
{% if static %}
|
||||||
|
<a href="/" class="delete">{{ label }}</a>
|
||||||
|
{% else %}
|
||||||
{% include 'snippets/toggle/toggle_button.html' with label=label class="delete" nonbutton=True %}
|
{% include 'snippets/toggle/toggle_button.html' with label=label class="delete" nonbutton=True %}
|
||||||
|
{% endif %}
|
||||||
</header>
|
</header>
|
||||||
{% block modal-form-open %}{% endblock %}
|
{% block modal-form-open %}{% endblock %}
|
||||||
{% if not no_body %}
|
{% if not no_body %}
|
||||||
|
@ -27,6 +31,10 @@
|
||||||
</footer>
|
</footer>
|
||||||
{% block modal-form-close %}{% endblock %}
|
{% block modal-form-close %}{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
|
{% if static %}
|
||||||
|
<a href="/" class="modal-close is-large">{{ label }}</a>
|
||||||
|
{% else %}
|
||||||
{% include 'snippets/toggle/toggle_button.html' with label=label class="modal-close is-large" nonbutton=True %}
|
{% include 'snippets/toggle/toggle_button.html' with label=label class="modal-close is-large" nonbutton=True %}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,6 @@ Finish "{{ book_title }}"
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% include "snippets/reading_modals/finish_reading_modal.html" with book=book active=True %}
|
{% include "snippets/reading_modals/finish_reading_modal.html" with book=book active=True static=True %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -9,6 +9,6 @@ Start "{{ book_title }}"
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% include "snippets/reading_modals/start_reading_modal.html" with book=book active=True %}
|
{% include "snippets/reading_modals/start_reading_modal.html" with book=book active=True static=True %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -9,6 +9,6 @@ Want to Read "{{ book_title }}"
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% include "snippets/reading_modals/want_to_read_modal.html" with book=book active=True %}
|
{% include "snippets/reading_modals/want_to_read_modal.html" with book=book active=True static=True %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -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 New Issue