From c3ec25dbf80188211ec8720dd57753167c4b90b6 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 28 Dec 2021 12:57:45 -0800 Subject: [PATCH 01/24] Simplifies query for earliest year --- bookwyrm/views/annual_summary.py | 42 ++++++-------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/bookwyrm/views/annual_summary.py b/bookwyrm/views/annual_summary.py index 07838d6e5..2ed27e718 100644 --- a/bookwyrm/views/annual_summary.py +++ b/bookwyrm/views/annual_summary.py @@ -3,7 +3,7 @@ from datetime import date from uuid import uuid4 from django.contrib.auth.decorators import login_required -from django.db.models import Case, When, Avg, Sum +from django.db.models import Avg, Sum, Min, Case, When from django.http import Http404 from django.shortcuts import redirect from django.template.response import TemplateResponse @@ -185,7 +185,12 @@ def privacy_verification(request, user, year, year_key): def is_year_available(user, year): """return boolean""" - earliest_year = int(get_earliest_year(user, year)) + earliest_year = user.readthrough_set.filter(finish_date__isnull=False).aggregate( + Min("finish_date") + )["finish_date__min"] + if not earliest_year: + return False + earliest_year = earliest_year.year today = date.today() year = int(year) if earliest_year <= year < today.year: @@ -196,39 +201,6 @@ def is_year_available(user, year): return False -def get_earliest_year(user, year): - """return the earliest finish_date or shelved_date year for user books in read shelf""" - - read_shelfbooks = models.ShelfBook.objects.filter(user__id=user.id).filter( - shelf__identifier__exact="read" - ) - read_shelfbooks_list = list(read_shelfbooks.values("book", "shelved_date")) - - book_dates = [] - - for book in read_shelfbooks_list: - earliest_finished = ( - models.ReadThrough.objects.filter(user__id=user.id) - .filter(book_id=book["book"]) - .exclude(finish_date__exact=None) - .order_by("finish_date") - .values("finish_date") - .first() - ) - - if earliest_finished: - book_dates.append( - min(earliest_finished["finish_date"], book["shelved_date"]) - ) - else: - book_dates.append(book["shelved_date"]) - - if book_dates: - return min(book_dates).year - - return year - - def get_books_from_shelfbooks(books_ids): """return an ordered QuerySet of books from a list""" From 6ca57ae314e982c73dd5a6697b0b5b5774f9548a Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 29 Dec 2021 09:43:06 -0800 Subject: [PATCH 02/24] Linter fixes --- bookwyrm/tests/views/test_annual_summary.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bookwyrm/tests/views/test_annual_summary.py b/bookwyrm/tests/views/test_annual_summary.py index d62540288..0860d80f3 100644 --- a/bookwyrm/tests/views/test_annual_summary.py +++ b/bookwyrm/tests/views/test_annual_summary.py @@ -1,7 +1,7 @@ """testing the annual summary page""" from datetime import datetime -import pytz from unittest.mock import patch +import pytz from django.contrib.auth.models import AnonymousUser from django.http import Http404 @@ -124,7 +124,7 @@ class AnnualSummary(TestCase): def test_annual_summary_page_with_review(self, *_): """there are so many views, this just makes sure it LOADS""" - self.review = models.Review.objects.create( + models.Review.objects.create( name="Review name", content="test content", rating=3.0, From f9e9dc55d5c95840c3e0b2bd5c6ec2e754cdd7f6 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 29 Dec 2021 09:58:42 -0800 Subject: [PATCH 03/24] Updates tests --- bookwyrm/tests/views/test_annual_summary.py | 17 ++++++----------- bookwyrm/views/annual_summary.py | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/bookwyrm/tests/views/test_annual_summary.py b/bookwyrm/tests/views/test_annual_summary.py index 0860d80f3..c48ad3b09 100644 --- a/bookwyrm/tests/views/test_annual_summary.py +++ b/bookwyrm/tests/views/test_annual_summary.py @@ -100,13 +100,10 @@ class AnnualSummary(TestCase): @patch("bookwyrm.activitystreams.add_book_statuses_task.delay") def test_annual_summary_page(self, *_): """there are so many views, this just makes sure it LOADS""" - - shelf = self.local_user.shelf_set.filter(identifier="read").first() - models.ShelfBook.objects.create( - book=self.book, + models.ReadThrough.objects.create( user=self.local_user, - shelf=shelf, - shelved_date=make_date(2020, 1, 1), + book=self.book, + finish_date=make_date(2020, 1, 1) ) view = views.AnnualSummary.as_view() @@ -132,12 +129,10 @@ class AnnualSummary(TestCase): book=self.book, ) - shelf = self.local_user.shelf_set.filter(identifier="read").first() - models.ShelfBook.objects.create( - book=self.book, + models.ReadThrough.objects.create( user=self.local_user, - shelf=shelf, - shelved_date=make_date(2020, 1, 1), + book=self.book, + finish_date=make_date(2020, 1, 1) ) view = views.AnnualSummary.as_view() diff --git a/bookwyrm/views/annual_summary.py b/bookwyrm/views/annual_summary.py index 2ed27e718..00ca4210d 100644 --- a/bookwyrm/views/annual_summary.py +++ b/bookwyrm/views/annual_summary.py @@ -189,7 +189,7 @@ def is_year_available(user, year): Min("finish_date") )["finish_date__min"] if not earliest_year: - return False + return True earliest_year = earliest_year.year today = date.today() year = int(year) From 41fb44a46ad36a38c9e50b39b7db9634f07011cf Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 29 Dec 2021 10:07:27 -0800 Subject: [PATCH 04/24] Python formatting --- bookwyrm/tests/views/test_annual_summary.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/bookwyrm/tests/views/test_annual_summary.py b/bookwyrm/tests/views/test_annual_summary.py index c48ad3b09..32439eab2 100644 --- a/bookwyrm/tests/views/test_annual_summary.py +++ b/bookwyrm/tests/views/test_annual_summary.py @@ -101,9 +101,7 @@ class AnnualSummary(TestCase): def test_annual_summary_page(self, *_): """there are so many views, this just makes sure it LOADS""" models.ReadThrough.objects.create( - user=self.local_user, - book=self.book, - finish_date=make_date(2020, 1, 1) + user=self.local_user, book=self.book, finish_date=make_date(2020, 1, 1) ) view = views.AnnualSummary.as_view() @@ -130,9 +128,7 @@ class AnnualSummary(TestCase): ) models.ReadThrough.objects.create( - user=self.local_user, - book=self.book, - finish_date=make_date(2020, 1, 1) + user=self.local_user, book=self.book, finish_date=make_date(2020, 1, 1) ) view = views.AnnualSummary.as_view() From 9facaf404f6d18836f078822f106d8ea7bcfde81 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 29 Dec 2021 10:20:54 -0800 Subject: [PATCH 05/24] Validates html in feed views --- bookwyrm/templates/feed/status.html | 2 +- bookwyrm/tests/views/test_feed.py | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/bookwyrm/templates/feed/status.html b/bookwyrm/templates/feed/status.html index 8dcad0886..e7b9280d7 100644 --- a/bookwyrm/templates/feed/status.html +++ b/bookwyrm/templates/feed/status.html @@ -31,7 +31,7 @@ {% endif %} {% endfor %} -
+
{% include 'snippets/status/status.html' with status=status main=True %}
diff --git a/bookwyrm/tests/views/test_feed.py b/bookwyrm/tests/views/test_feed.py index 63264b800..475bebeb7 100644 --- a/bookwyrm/tests/views/test_feed.py +++ b/bookwyrm/tests/views/test_feed.py @@ -13,6 +13,7 @@ from django.test.client import RequestFactory from bookwyrm import models from bookwyrm import views from bookwyrm.activitypub import ActivitypubResponse +from bookwyrm.tests.validate_html import validate_html @patch("bookwyrm.activitystreams.ActivityStream.get_activity_stream") @@ -58,7 +59,7 @@ class FeedViews(TestCase): request.user = self.local_user result = view(request, "home") self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) def test_status_page(self, *_): @@ -72,7 +73,7 @@ class FeedViews(TestCase): is_api.return_value = False result = view(request, "mouse", status.id) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) with patch("bookwyrm.views.feed.is_api_request") as is_api: @@ -139,7 +140,7 @@ class FeedViews(TestCase): is_api.return_value = False result = view(request, "mouse", status.id) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) with patch("bookwyrm.views.feed.is_api_request") as is_api: @@ -159,7 +160,7 @@ class FeedViews(TestCase): is_api.return_value = False result = view(request, "mouse", status.id) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) with patch("bookwyrm.views.feed.is_api_request") as is_api: @@ -175,7 +176,7 @@ class FeedViews(TestCase): request.user = self.local_user result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) def test_direct_messages_page_user(self, *_): @@ -185,7 +186,7 @@ class FeedViews(TestCase): request.user = self.local_user result = view(request, "nutria") self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) self.assertEqual(result.context_data["partner"], self.another_user) From 161532f8a8bb660b558a7c4b0a04473538cac006 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 29 Dec 2021 10:37:21 -0800 Subject: [PATCH 06/24] Adds validate_html to announcement page tests --- bookwyrm/tests/views/admin/test_announcements.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bookwyrm/tests/views/admin/test_announcements.py b/bookwyrm/tests/views/admin/test_announcements.py index 44b5d5b67..fadd3d862 100644 --- a/bookwyrm/tests/views/admin/test_announcements.py +++ b/bookwyrm/tests/views/admin/test_announcements.py @@ -5,6 +5,7 @@ from django.test import TestCase from django.test.client import RequestFactory from bookwyrm import forms, models, views +from bookwyrm.tests.validate_html import validate_html class AnnouncementViews(TestCase): @@ -38,7 +39,7 @@ class AnnouncementViews(TestCase): result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) def test_announcements_page_empty(self): @@ -51,7 +52,7 @@ class AnnouncementViews(TestCase): result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) def test_announcement_page(self): @@ -68,7 +69,7 @@ class AnnouncementViews(TestCase): result = view(request, announcement.id) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) def test_create_announcement(self): @@ -138,5 +139,5 @@ class AnnouncementViews(TestCase): result = view(request, self.local_user.localname) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) From 1e27b64af43b18fc89210b2b0f23d4af0ed86410 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 29 Dec 2021 10:39:47 -0800 Subject: [PATCH 07/24] Valid dl html syntax on announcement page --- .../settings/announcements/announcement.html | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/bookwyrm/templates/settings/announcements/announcement.html b/bookwyrm/templates/settings/announcements/announcement.html index 37dba06fe..8b49f4f48 100644 --- a/bookwyrm/templates/settings/announcements/announcement.html +++ b/bookwyrm/templates/settings/announcements/announcement.html @@ -31,35 +31,29 @@
-
-
{% trans "Visible:" %}
-
- {% if announcement in active_announcements %} - {% trans "True" %} - {% else %} - {% trans "False" %} - {% endif %} -
-
+
{% trans "Visible:" %}
+
+ + {% if announcement in active_announcements %} + {% trans "True" %} + {% else %} + {% trans "False" %} + {% endif %} + +
{% if announcement.start_date %} -
-
{% trans "Start date:" %}
-
{{ announcement.start_date|naturalday }}
-
+
{% trans "Start date:" %}
+
{{ announcement.start_date|naturalday }}
{% endif %} {% if announcement.end_date %} -
-
{% trans "End date:" %}
-
{{ announcement.end_date|naturalday }}
-
+
{% trans "End date:" %}
+
{{ announcement.end_date|naturalday }}
{% endif %} -
-
{% trans "Active:" %}
-
{{ announcement.active }}
-
+
{% trans "Active:" %}
+
{{ announcement.active }}
From 3770713e0714e5df502bb19da6529c1cd0a1d8d0 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 29 Dec 2021 10:44:04 -0800 Subject: [PATCH 08/24] Validate html in discover page tests --- bookwyrm/tests/views/test_discover.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bookwyrm/tests/views/test_discover.py b/bookwyrm/tests/views/test_discover.py index b2a82241f..dcfc2bf25 100644 --- a/bookwyrm/tests/views/test_discover.py +++ b/bookwyrm/tests/views/test_discover.py @@ -4,8 +4,8 @@ from django.contrib.auth.models import AnonymousUser from django.test import TestCase from django.test.client import RequestFactory -from bookwyrm import models -from bookwyrm import views +from bookwyrm import models, views +from bookwyrm.tests.validate_html import validate_html class DiscoverViews(TestCase): @@ -39,7 +39,7 @@ class DiscoverViews(TestCase): result = view(request) self.assertEqual(mock.call_count, 1) self.assertEqual(result.status_code, 200) - result.render() + validate_html(result.render()) @patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async") @patch("bookwyrm.activitystreams.add_status_task.delay") @@ -67,7 +67,7 @@ class DiscoverViews(TestCase): result = view(request) self.assertEqual(mock.call_count, 1) self.assertEqual(result.status_code, 200) - result.render() + validate_html(result.render()) def test_discover_page_logged_out(self): """there are so many views, this just makes sure it LOADS""" From 8e89d020934f69b91758aa68ca32cb9d4709697b Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 29 Dec 2021 11:10:11 -0800 Subject: [PATCH 09/24] Fixes html form for editing lists --- bookwyrm/templates/lists/curate.html | 4 +- bookwyrm/templates/lists/form.html | 81 ++++++++++++++++++++++------ bookwyrm/tests/views/test_list.py | 31 +++++------ 3 files changed, 83 insertions(+), 33 deletions(-) diff --git a/bookwyrm/templates/lists/curate.html b/bookwyrm/templates/lists/curate.html index 638d86b88..13de89c16 100644 --- a/bookwyrm/templates/lists/curate.html +++ b/bookwyrm/templates/lists/curate.html @@ -54,13 +54,13 @@ {% csrf_token %} - +
{% csrf_token %} - +
diff --git a/bookwyrm/templates/lists/form.html b/bookwyrm/templates/lists/form.html index 25dc01e63..ae19e5db6 100644 --- a/bookwyrm/templates/lists/form.html +++ b/bookwyrm/templates/lists/form.html @@ -18,24 +18,73 @@
{% trans "List curation:" %} - +
+ + +

+ {% trans "Only you can add and remove books to this list" %} +

+
- +
+ + +

+ {% trans "Anyone can suggest books, subject to your approval" %} +

+
- +
+ + +

+ {% trans "Anyone can add books to this list" %} +

+
+ +
+ + +

+ {% trans "Group members can add to and remove from this list" %} +

- +
diff --git a/bookwyrm/tests/views/test_list.py b/bookwyrm/tests/views/test_list.py index fd4d2d767..3d9b6d241 100644 --- a/bookwyrm/tests/views/test_list.py +++ b/bookwyrm/tests/views/test_list.py @@ -10,6 +10,7 @@ from django.test.client import RequestFactory from bookwyrm import models, views from bookwyrm.activitypub import ActivitypubResponse +from bookwyrm.tests.validate_html import validate_html # pylint: disable=unused-argument class ListViews(TestCase): @@ -84,14 +85,14 @@ class ListViews(TestCase): result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) request.user = self.anonymous_user result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) def test_saved_lists_page(self): @@ -110,7 +111,7 @@ class ListViews(TestCase): result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) self.assertEqual(result.context_data["lists"].object_list, [booklist]) @@ -127,7 +128,7 @@ class ListViews(TestCase): result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) self.assertEqual(len(result.context_data["lists"].object_list), 0) @@ -188,7 +189,7 @@ class ListViews(TestCase): is_api.return_value = False result = view(request, self.list.id) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) def test_list_page_sorted(self): @@ -210,7 +211,7 @@ class ListViews(TestCase): is_api.return_value = False result = view(request, self.list.id) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) request = self.factory.get("/?sort_by=title") @@ -219,7 +220,7 @@ class ListViews(TestCase): is_api.return_value = False result = view(request, self.list.id) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) request = self.factory.get("/?sort_by=rating") @@ -228,7 +229,7 @@ class ListViews(TestCase): is_api.return_value = False result = view(request, self.list.id) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) request = self.factory.get("/?sort_by=sdkfh") @@ -237,7 +238,7 @@ class ListViews(TestCase): is_api.return_value = False result = view(request, self.list.id) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) def test_list_page_empty(self): @@ -250,7 +251,7 @@ class ListViews(TestCase): is_api.return_value = False result = view(request, self.list.id) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) def test_list_page_logged_out(self): @@ -271,7 +272,7 @@ class ListViews(TestCase): is_api.return_value = False result = view(request, self.list.id) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) def test_list_page_json_view(self): @@ -355,7 +356,7 @@ class ListViews(TestCase): result = view(request, self.list.id) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) request.user = self.anonymous_user @@ -375,7 +376,7 @@ class ListViews(TestCase): result = view(request, self.local_user.localname) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) def test_user_lists_page_logged_out(self): @@ -404,7 +405,7 @@ class ListViews(TestCase): with patch("bookwyrm.views.list.is_api_request") as is_api: is_api.return_value = False with self.assertRaises(Http404): - result = view(request, self.list.id, "") + view(request, self.list.id, "") def test_embed_call_with_key(self): """there are so many views, this just makes sure it LOADS""" @@ -427,5 +428,5 @@ class ListViews(TestCase): result = view(request, self.list.id, embed_key) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) From 4e1b155c6c396aaabefb72fa2d44d3a80da46c45 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 29 Dec 2021 11:21:21 -0800 Subject: [PATCH 10/24] Encode characters in iframe copy text --- bookwyrm/templates/lists/list.html | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/lists/list.html b/bookwyrm/templates/lists/list.html index 836ca864e..434ecd944 100644 --- a/bookwyrm/templates/lists/list.html +++ b/bookwyrm/templates/lists/list.html @@ -172,7 +172,7 @@
@@ -191,7 +191,16 @@ {% trans "Embed this list on a website" %}
- +
From 3e550a13adc32b0f3635ed8822752361563e2883 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 29 Dec 2021 11:31:26 -0800 Subject: [PATCH 11/24] Unique names for shelve forms --- bookwyrm/templates/lists/list.html | 2 +- .../templates/snippets/reading_modals/finish_reading_modal.html | 2 +- .../snippets/reading_modals/progress_update_modal.html | 2 +- .../templates/snippets/reading_modals/start_reading_modal.html | 2 +- .../templates/snippets/reading_modals/want_to_read_modal.html | 2 +- .../snippets/shelve_button/shelve_button_dropdown_options.html | 2 +- .../templates/snippets/shelve_button/shelve_button_options.html | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bookwyrm/templates/lists/list.html b/bookwyrm/templates/lists/list.html index 434ecd944..8bf7c052c 100644 --- a/bookwyrm/templates/lists/list.html +++ b/bookwyrm/templates/lists/list.html @@ -56,7 +56,7 @@
{{ book|book_description|to_markdown|default:""|safe|truncatewords_html:20 }}
- {% include 'snippets/shelve_button/shelve_button.html' %} + {% include 'snippets/shelve_button/shelve_button.html' with book=book %} {% endwith %} diff --git a/bookwyrm/templates/snippets/reading_modals/finish_reading_modal.html b/bookwyrm/templates/snippets/reading_modals/finish_reading_modal.html index a35ed9e0b..fe35ee7e6 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/progress_update_modal.html b/bookwyrm/templates/snippets/reading_modals/progress_update_modal.html index 422f7056e..3e0fd45e4 100644 --- a/bookwyrm/templates/snippets/reading_modals/progress_update_modal.html +++ b/bookwyrm/templates/snippets/reading_modals/progress_update_modal.html @@ -6,7 +6,7 @@ {% endblock %} {% block modal-form-open %} - + {% csrf_token %} {% endblock %} diff --git a/bookwyrm/templates/snippets/reading_modals/start_reading_modal.html b/bookwyrm/templates/snippets/reading_modals/start_reading_modal.html index 423f77ebe..60c7a89e7 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 2fb976bf1..d6bc4d70a 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/shelve_button/shelve_button_dropdown_options.html b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html index 8c1881ce9..d418b7189 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 %} - + + {% csrf_token %} +
+
+
- -
+
+ +
+
+ +
+ + {% endif %} + {% if list.user == request.user or list.curation == 'open' and item.user == request.user or list.group|is_member:request.user %} - From 383f9fa228e94fea5e17fd6f264aaa5b886ef261 Mon Sep 17 00:00:00 2001 From: Joachim Date: Wed, 29 Dec 2021 20:41:11 +0100 Subject: [PATCH 13/24] Front-end: Update Feed summary card style Now the header's background is contained by the border-radius --- bookwyrm/templates/feed/summary_card.html | 50 ++++++++++++----------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/bookwyrm/templates/feed/summary_card.html b/bookwyrm/templates/feed/summary_card.html index 02718cdd9..e76bef912 100644 --- a/bookwyrm/templates/feed/summary_card.html +++ b/bookwyrm/templates/feed/summary_card.html @@ -1,29 +1,31 @@ -{% extends 'components/card.html' %} {% load i18n %} -{% block card-header %} -

- - - {% blocktrans %}{{ year }} in the books{% endblocktrans %} -

+
+
+

+ + + {% blocktrans %}{{ year }} in the books{% endblocktrans %} +

-
- {% trans "Dismiss message" as button_text %} - -
-{% endblock %} +
+ {% trans "Dismiss message" as button_text %} + +
+
-{% block card-content %} -

-{% blocktrans %}The end of the year is the best moment to take stock of all the books read during the last 12 months. How many pages have you read? Which book is your best-rated of the year? We compiled these stats, and more!{% endblocktrans %} -

+
+

+ {% blocktrans %}The end of the year is the best moment to take stock of all the books read during the last 12 months. How many pages have you read? Which book is your best-rated of the year? We compiled these stats, and more!{% endblocktrans %} +

-

- - {% blocktrans %}Discover your stats for {{ year }}!{% endblocktrans %} - -

-{% endblock %} +

+ + {% blocktrans %}Discover your stats for {{ year }}!{% endblocktrans %} + +

+
+ +
From 6075a8843825ddfac0385063039703208ac3a615 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 29 Dec 2021 11:45:07 -0800 Subject: [PATCH 14/24] Validate html in get started views tests --- bookwyrm/tests/views/test_get_started.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bookwyrm/tests/views/test_get_started.py b/bookwyrm/tests/views/test_get_started.py index 6d1819a4b..9d0222054 100644 --- a/bookwyrm/tests/views/test_get_started.py +++ b/bookwyrm/tests/views/test_get_started.py @@ -5,6 +5,7 @@ from django.test import TestCase from django.test.client import RequestFactory from bookwyrm import forms, models, views +from bookwyrm.tests.validate_html import validate_html @patch("bookwyrm.activitystreams.populate_stream_task.delay") @@ -40,7 +41,7 @@ class GetStartedViews(TestCase): result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) @patch("bookwyrm.suggested_users.rerank_suggestions_task.delay") @@ -72,7 +73,7 @@ class GetStartedViews(TestCase): result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) def test_books_view_with_query(self, _): @@ -84,7 +85,7 @@ class GetStartedViews(TestCase): result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) @patch("bookwyrm.suggested_users.rerank_suggestions_task.delay") @@ -117,7 +118,7 @@ class GetStartedViews(TestCase): result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) @patch("bookwyrm.suggested_users.SuggestedUsers.get_suggestions") @@ -130,5 +131,5 @@ class GetStartedViews(TestCase): result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) From 0968802fd30a2559c6da41b03fbebc71fbccaf85 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 29 Dec 2021 11:45:17 -0800 Subject: [PATCH 15/24] Adds alt tag to logo --- bookwyrm/templates/get_started/layout.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bookwyrm/templates/get_started/layout.html b/bookwyrm/templates/get_started/layout.html index eef5a9e27..32db56d5d 100644 --- a/bookwyrm/templates/get_started/layout.html +++ b/bookwyrm/templates/get_started/layout.html @@ -10,7 +10,12 @@