From 0d2c6e63d18f591678c1ffc697b43fac69a324a0 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 11 Jan 2022 09:50:04 -0800 Subject: [PATCH] Converts create readthrough to modal --- bookwyrm/forms.py | 5 ++ .../templates/book/add_readthrough_modal.html | 28 ++++++++++ bookwyrm/templates/book/book.html | 24 +++----- .../templates/snippets/readthrough_form.html | 1 + bookwyrm/urls.py | 2 +- bookwyrm/views/__init__.py | 2 +- bookwyrm/views/reading.py | 55 +++++++++++-------- 7 files changed, 75 insertions(+), 42 deletions(-) create mode 100644 bookwyrm/templates/book/add_readthrough_modal.html diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index 7ba7bd97b..37cb2e872 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -478,3 +478,8 @@ class SortListForm(forms.Form): ("descending", _("Descending")), ), ) + +class ReadThroughForm(CustomForm): + class Meta: + model = models.ReadThrough + fields = ["user", "book", "start_date", "finish_date"] diff --git a/bookwyrm/templates/book/add_readthrough_modal.html b/bookwyrm/templates/book/add_readthrough_modal.html new file mode 100644 index 000000000..45cbb2aa5 --- /dev/null +++ b/bookwyrm/templates/book/add_readthrough_modal.html @@ -0,0 +1,28 @@ +{% extends "components/modal.html" %} +{% load i18n %} +{% load utilities %} + +{% block modal-title %} +{% blocktrans trimmed with title=book|book_title %} +Add read dates for "{{ title }}" +{% endblocktrans %} +{% endblock %} + +{% block modal-form-open %} +
+{% endblock %} + +{% block modal-body %} +{% include 'snippets/readthrough_form.html' with readthrough=None %} +{% endblock %} + +{% block modal-footer %} + +{% if not static %} + +{% endif %} +{% endblock %} + +{% block modal-form-close %} +
+{% endblock %} diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index 19dbccbd6..38dffd20a 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -237,24 +237,16 @@

{% trans "Your reading activity" %}

- {% trans "Add read dates" as button_text %} - {% include 'snippets/toggle/open_button.html' with text=button_text icon_with_text="plus" class="is-small" controls_text="add_readthrough" focus="add_readthrough_focus_" %} +
- + {% include "book/add_readthrough_modal.html" with id="add-readthrough" %} + {% if not readthroughs.exists %}

{% trans "You don't have any reading activity for this book." %}

{% endif %} diff --git a/bookwyrm/templates/snippets/readthrough_form.html b/bookwyrm/templates/snippets/readthrough_form.html index 295ad7c6e..1558dada4 100644 --- a/bookwyrm/templates/snippets/readthrough_form.html +++ b/bookwyrm/templates/snippets/readthrough_form.html @@ -4,6 +4,7 @@ {% csrf_token %} +