Merge branch 'main' into quote-page

This commit is contained in:
Mouse Reeve
2021-09-05 16:08:54 -07:00
15 changed files with 497 additions and 381 deletions

View File

@ -14,7 +14,11 @@
<h2 class="modal-card-title is-flex-shrink-1" id="modal_card_title_{{ controls_text }}_{{ controls_uid }}">
{% block modal-title %}{% endblock %}
</h2>
{% include 'snippets/toggle/toggle_button.html' with label=label class="delete" nonbutton=True %}
{% if static %}
<a href="/" class="delete">{{ label }}</a>
{% else %}
{% include 'snippets/toggle/toggle_button.html' with label=label class="delete" nonbutton=True %}
{% endif %}
</header>
{% block modal-form-open %}{% endblock %}
{% if not no_body %}
@ -27,6 +31,10 @@
</footer>
{% block modal-form-close %}{% endblock %}
</div>
{% include 'snippets/toggle/toggle_button.html' with label=label class="modal-close is-large" nonbutton=True %}
{% 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 %}
{% endif %}
</div>

View File

@ -9,6 +9,6 @@ Finish "{{ book_title }}"
{% 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 %}

View File

@ -9,6 +9,6 @@ Start "{{ book_title }}"
{% 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 %}

View File

@ -9,6 +9,6 @@ Want to Read "{{ book_title }}"
{% 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 %}

View File

@ -14,6 +14,6 @@ draft: an existing Status object that is providing default values for input fiel
id="id_content_{{ type }}_{{ book.id }}{{ reply_parent.id }}"
placeholder="{{ placeholder }}"
aria-label="{% if reply_parent %}{% trans 'Reply' %}{% else %}{% trans 'Content' %}{% endif %}"
{% if not optional and type != "quotation" %}required{% endif %}
{% if not optional and type != "quotation" and type != "review" %}required{% endif %}
>{% if reply_parent %}{{ reply_parent|mentions:request.user }}{% endif %}{% if mention %}@{{ mention|username }} {% endif %}{{ draft.content|default:'' }}</textarea>

View File

@ -11,8 +11,6 @@ draft: the content of an existing Status object to be edited (used in delete and
uuid: a unique identifier used to make html "id" attributes unique and clarify javascript controls
{% endcomment %}
{% with type="review" %}
{% block pre_content_additions %}
<div class="field">
<label class="label" for="id_name_{{ book.id }}">{% trans "Title:" %}</label>
@ -31,5 +29,3 @@ uuid: a unique identifier used to make html "id" attributes unique and clarify j
{% block content_label %}
{% trans "Review:" %}
{% endblock %}
{% endwith %}

View File

@ -24,11 +24,26 @@
<div class="tabs">
<ul>
<li class="{% if shelf.identifier == 'all' %}is-active{% endif %}">
<a href="{% url 'user-shelves' user|username %}"{% if shelf.identifier == 'all' %} aria-current="page"{% endif %}>{% trans "All books" %}</a>
<a href="{% url 'user-shelves' user|username %}"{% if shelf.identifier == 'all' %} aria-current="page"{% endif %}>
{% trans "All books" %}
</a>
</li>
{% for shelf_tab in shelves %}
<li class="{% if shelf_tab.identifier == shelf.identifier %}is-active{% endif %}">
<a href="{{ shelf_tab.local_path }}"{% if shelf_tab.identifier == shelf.identifier %} aria-current="page"{% endif %}>{% if shelf_tab.identifier == 'to-read' %}{% trans "To Read" %}{% elif shelf_tab.identifier == 'reading' %}{% trans "Currently Reading" %}{% elif shelf_tab.identifier == 'read' %}{% trans "Read" %}{% else %}{{ shelf_tab.name }}{% endif %}</a>
<a
href="{{ shelf_tab.local_path }}"
{% if shelf_tab.identifier == shelf.identifier %} aria-current="page"{% endif %}
>
{% if shelf_tab.identifier == 'to-read' %}
{% trans "To Read" %}
{% elif shelf_tab.identifier == 'reading' %}
{% trans "Currently Reading" %}
{% elif shelf_tab.identifier == 'read' %}
{% trans "Read" %}
{% else %}
{{ shelf_tab.name }}
{% endif %}
</a>
</li>
{% endfor %}
</ul>
@ -55,6 +70,23 @@
<span class="subtitle">
{% include 'snippets/privacy-icons.html' with item=shelf %}
</span>
{% with count=books.paginator.count %}
{% if count %}
<p class="help">
{% blocktrans trimmed count counter=count with formatted_count=count|intcomma %}
{{ formatted_count }} book
{% plural %}
{{ formatted_count }} books
{% endblocktrans %}
{% if books.has_other_pages %}
{% blocktrans trimmed with start=books.start_index end=books.end_index %}
(showing {{ start }}-{{ end }})
{% endblocktrans %}
{% endif %}
</p>
{% endif %}
{% endwith %}
</h2>
</div>
{% if is_self and shelf.id %}

View File

@ -31,6 +31,7 @@ class ReadingStatus(View):
}.get(status)
if not template:
return HttpResponseNotFound()
# redirect if we're already on this shelf
return TemplateResponse(request, f"reading_progress/{template}", {"book": book})
def post(self, request, status, book_id):
@ -58,11 +59,15 @@ class ReadingStatus(View):
)
.first()
)
referer = request.headers.get("Referer", "/")
if "reading-status" in referer:
referer = "/"
if current_status_shelfbook is not None:
if current_status_shelfbook.shelf.identifier != desired_shelf.identifier:
current_status_shelfbook.delete()
else: # It already was on the shelf
return redirect(request.headers.get("Referer", "/"))
return redirect(referer)
models.ShelfBook.objects.create(
book=book, shelf=desired_shelf, user=request.user
@ -87,8 +92,7 @@ class ReadingStatus(View):
else:
privacy = request.POST.get("privacy")
handle_reading_status(request.user, desired_shelf, book, privacy)
return redirect(request.headers.get("Referer", "/"))
return redirect(referer)
@login_required