From 33ca7b4b763c118cf84ee85205e64ccd1355b220 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 4 May 2021 08:54:53 -0700 Subject: [PATCH 1/3] Adds datepicker script dependencies to templates --- bookwyrm/templates/author.html | 3 +++ bookwyrm/templates/book/book.html | 1 + bookwyrm/templates/book/edit_book.html | 8 ++++++-- bookwyrm/templates/book/editions.html | 4 ++++ bookwyrm/templates/edit_author.html | 4 ++++ bookwyrm/templates/feed/feed_layout.html | 1 + bookwyrm/templates/get_started/books.html | 4 ++++ bookwyrm/templates/user/layout.html | 5 +++++ 8 files changed, 28 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/author.html b/bookwyrm/templates/author.html index bc1034a8d..0ef876fd3 100644 --- a/bookwyrm/templates/author.html +++ b/bookwyrm/templates/author.html @@ -39,3 +39,6 @@ {% endblock %} +{% block scripts %} +{% include 'snippets/datepicker_js.html' %} +{% endblock %} diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index 40da64861..53be123d8 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -333,4 +333,5 @@ {% block scripts %} +{% include 'snippets/datepicker_js.html' %} {% endblock %} diff --git a/bookwyrm/templates/book/edit_book.html b/bookwyrm/templates/book/edit_book.html index 8ebbeaae6..095439d14 100644 --- a/bookwyrm/templates/book/edit_book.html +++ b/bookwyrm/templates/book/edit_book.html @@ -133,7 +133,7 @@

- +

{% for error in form.first_published_date.errors %}

{{ error | escape }}

@@ -141,7 +141,7 @@

- +

{% for error in form.published_date.errors %}

{{ error | escape }}

@@ -245,3 +245,7 @@ {% endblock %} + +{% block scripts %} +{% include 'snippets/datepicker_js.html' %} +{% endblock %} diff --git a/bookwyrm/templates/book/editions.html b/bookwyrm/templates/book/editions.html index efbe15663..8af85aced 100644 --- a/bookwyrm/templates/book/editions.html +++ b/bookwyrm/templates/book/editions.html @@ -51,3 +51,7 @@ {% include 'snippets/pagination.html' with page=editions path=request.path %} {% endblock %} + +{% block scripts %} +{% include 'snippets/datepicker_js.html' %} +{% endblock %} diff --git a/bookwyrm/templates/edit_author.html b/bookwyrm/templates/edit_author.html index 542b57f95..ded8c4944 100644 --- a/bookwyrm/templates/edit_author.html +++ b/bookwyrm/templates/edit_author.html @@ -81,3 +81,7 @@ {% endblock %} + +{% block scripts %} +{% include 'snippets/datepicker_js.html' %} +{% endblock %} diff --git a/bookwyrm/templates/feed/feed_layout.html b/bookwyrm/templates/feed/feed_layout.html index 75fc1951a..431cf6dd7 100644 --- a/bookwyrm/templates/feed/feed_layout.html +++ b/bookwyrm/templates/feed/feed_layout.html @@ -105,4 +105,5 @@ {% block scripts %} +{% include 'snippets/datepicker_js.html' %} {% endblock %} diff --git a/bookwyrm/templates/get_started/books.html b/bookwyrm/templates/get_started/books.html index 9613508b9..e3fd87bbd 100644 --- a/bookwyrm/templates/get_started/books.html +++ b/bookwyrm/templates/get_started/books.html @@ -64,3 +64,7 @@ {% endblock %} + +{% block scripts %} +{% include 'snippets/datepicker_js.html' %} +{% endblock %} diff --git a/bookwyrm/templates/user/layout.html b/bookwyrm/templates/user/layout.html index 661d80781..1aa762027 100644 --- a/bookwyrm/templates/user/layout.html +++ b/bookwyrm/templates/user/layout.html @@ -81,3 +81,8 @@ {% block panel %}{% endblock %} {% endblock %} + + +{% block scripts %} +{% include 'snippets/datepicker_js.html' %} +{% endblock %} From 869cfa6d341f25ee25d8576adcdc2e3b8d239b9c Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 4 May 2021 09:04:21 -0700 Subject: [PATCH 2/3] Replaces date elements with datepicker --- bookwyrm/templates/book/edit_book.html | 12 ++++++++++-- bookwyrm/templates/snippets/datepicker_js.html | 3 +++ bookwyrm/templates/snippets/readthrough_form.html | 12 ++++++++++-- .../snippets/shelve_button/finish_reading_modal.html | 12 ++++++++++-- .../snippets/shelve_button/start_reading_modal.html | 6 +++++- 5 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 bookwyrm/templates/snippets/datepicker_js.html diff --git a/bookwyrm/templates/book/edit_book.html b/bookwyrm/templates/book/edit_book.html index 095439d14..644e90c6e 100644 --- a/bookwyrm/templates/book/edit_book.html +++ b/bookwyrm/templates/book/edit_book.html @@ -133,7 +133,11 @@

- +

{% for error in form.first_published_date.errors %}

{{ error | escape }}

@@ -141,7 +145,11 @@

- +

{% for error in form.published_date.errors %}

{{ error | escape }}

diff --git a/bookwyrm/templates/snippets/datepicker_js.html b/bookwyrm/templates/snippets/datepicker_js.html new file mode 100644 index 000000000..abfadaaf8 --- /dev/null +++ b/bookwyrm/templates/snippets/datepicker_js.html @@ -0,0 +1,3 @@ + + + diff --git a/bookwyrm/templates/snippets/readthrough_form.html b/bookwyrm/templates/snippets/readthrough_form.html index c5be295e1..256fcea54 100644 --- a/bookwyrm/templates/snippets/readthrough_form.html +++ b/bookwyrm/templates/snippets/readthrough_form.html @@ -5,7 +5,11 @@
{# Only show progress for editing existing readthroughs #} @@ -28,6 +32,10 @@
diff --git a/bookwyrm/templates/snippets/shelve_button/finish_reading_modal.html b/bookwyrm/templates/snippets/shelve_button/finish_reading_modal.html index ca65bf06c..6d4ea5eac 100644 --- a/bookwyrm/templates/snippets/shelve_button/finish_reading_modal.html +++ b/bookwyrm/templates/snippets/shelve_button/finish_reading_modal.html @@ -17,13 +17,21 @@
diff --git a/bookwyrm/templates/snippets/shelve_button/start_reading_modal.html b/bookwyrm/templates/snippets/shelve_button/start_reading_modal.html index 213416836..47d620e0d 100644 --- a/bookwyrm/templates/snippets/shelve_button/start_reading_modal.html +++ b/bookwyrm/templates/snippets/shelve_button/start_reading_modal.html @@ -15,7 +15,11 @@
From b10f0b19c4ed6e5f34df60431318dcabba35ce5a Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 4 May 2021 09:49:24 -0700 Subject: [PATCH 3/3] Removes outdated test --- bookwyrm/tests/views/test_book.py | 33 ------------------------------- 1 file changed, 33 deletions(-) diff --git a/bookwyrm/tests/views/test_book.py b/bookwyrm/tests/views/test_book.py index dce50868f..2acdb369f 100644 --- a/bookwyrm/tests/views/test_book.py +++ b/bookwyrm/tests/views/test_book.py @@ -47,39 +47,6 @@ class BookViews(TestCase): ) models.SiteSettings.objects.create() - def test_date_regression(self): - """ensure that creating a new book actually saves the published date fields - - this was initially a regression due to using a custom date picker tag - """ - first_published_date = "2021-04-20" - published_date = "2022-04-20" - self.local_user.groups.add(self.group) - view = views.EditBook.as_view() - form = forms.EditionForm( - { - "title": "New Title", - "last_edited_by": self.local_user.id, - "first_published_date": first_published_date, - "published_date": published_date, - } - ) - request = self.factory.post("", form.data) - request.user = self.local_user - - with patch("bookwyrm.connectors.connector_manager.local_search"): - result = view(request) - result.render() - - self.assertContains( - result, - f'', - ) - self.assertContains( - result, - f'', - ) - def test_book_page(self): """there are so many views, this just makes sure it LOADS""" view = views.Book.as_view()