From 701bf4828bed46ee1f798cef5939714b3dfa9f58 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 28 Sep 2021 18:34:12 -0700 Subject: [PATCH 1/5] Improves html consistency for goal page --- bookwyrm/templates/snippets/goal_form.html | 10 ++++----- bookwyrm/tests/views/test_goal.py | 25 +++++++++++++++++++--- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/bookwyrm/templates/snippets/goal_form.html b/bookwyrm/templates/snippets/goal_form.html index 3afcf2ac..f4db3e96 100644 --- a/bookwyrm/templates/snippets/goal_form.html +++ b/bookwyrm/templates/snippets/goal_form.html @@ -16,21 +16,21 @@
- + + {% include 'snippets/privacy_select.html' with no_label=True current=goal.privacy uuid=goal.id %}
+ -

+

{% if goal %} {% trans "Cancel" as button_text %} {% include 'snippets/toggle/close_button.html' with text=button_text controls_text="show_edit_goal" %} {% endif %} -

+
diff --git a/bookwyrm/tests/views/test_goal.py b/bookwyrm/tests/views/test_goal.py index cb8c5d8e..741fca9c 100644 --- a/bookwyrm/tests/views/test_goal.py +++ b/bookwyrm/tests/views/test_goal.py @@ -1,12 +1,13 @@ """ test for app action functionality """ from unittest.mock import patch -from django.utils import timezone +from tidylib import tidy_document from django.contrib.auth.models import AnonymousUser from django.http import Http404 from django.template.response import TemplateResponse from django.test import TestCase from django.test.client import RequestFactory +from django.utils import timezone from bookwyrm import models, views @@ -61,7 +62,16 @@ class GoalViews(TestCase): request.user = self.local_user result = view(request, self.local_user.localname, self.year) - result.render() + html = result.render() + _, errors = tidy_document( + html.content, + options={ + "drop-empty-elements": False, + "warn-proprietary-attributes": False, + }, + ) + if errors: + raise Exception(errors) self.assertIsInstance(result, TemplateResponse) def test_goal_page_anonymous(self): @@ -92,7 +102,16 @@ class GoalViews(TestCase): request.user = self.rat result = view(request, self.local_user.localname, timezone.now().year) - result.render() + html = result.render() + _, errors = tidy_document( + html.content, + options={ + "drop-empty-elements": False, + "warn-proprietary-attributes": False, + }, + ) + if errors: + raise Exception(errors) self.assertIsInstance(result, TemplateResponse) def test_goal_page_private(self): From 46168a292be2c078f63dbae8fe6a39e70251e97f Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 29 Sep 2021 09:23:52 -0700 Subject: [PATCH 2/5] Moves info text to goal form snippet --- bookwyrm/templates/snippets/goal_card.html | 4 ---- bookwyrm/templates/snippets/goal_form.html | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bookwyrm/templates/snippets/goal_card.html b/bookwyrm/templates/snippets/goal_card.html index 329fea54..f13c26c7 100644 --- a/bookwyrm/templates/snippets/goal_card.html +++ b/bookwyrm/templates/snippets/goal_card.html @@ -7,11 +7,7 @@ {% endblock %} - {% block card-content %} -
-

{% blocktrans %}Set a goal for how many books you'll finish reading in {{ year }}, and track your progress throughout the year.{% endblocktrans %}

- {% include 'snippets/goal_form.html' %}
{% endblock %} diff --git a/bookwyrm/templates/snippets/goal_form.html b/bookwyrm/templates/snippets/goal_form.html index f4db3e96..28afbafe 100644 --- a/bookwyrm/templates/snippets/goal_form.html +++ b/bookwyrm/templates/snippets/goal_form.html @@ -1,4 +1,7 @@ {% load i18n %} +
+

{% blocktrans %}Set a goal for how many books you'll finish reading in {{ year }}, and track your progress throughout the year.{% endblocktrans %}

+
{% csrf_token %} From 5f3df11e560ab22bac354bc78b6b5624f4c6feb5 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 29 Sep 2021 09:24:51 -0700 Subject: [PATCH 3/5] Moves goal card to feed dir --- bookwyrm/templates/feed/feed.html | 2 +- bookwyrm/templates/{snippets => feed}/goal_card.html | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename bookwyrm/templates/{snippets => feed}/goal_card.html (100%) diff --git a/bookwyrm/templates/feed/feed.html b/bookwyrm/templates/feed/feed.html index b8e351c9..a6175199 100644 --- a/bookwyrm/templates/feed/feed.html +++ b/bookwyrm/templates/feed/feed.html @@ -25,7 +25,7 @@ {% if request.user.show_goal and not goal and tab.key == 'home' %} {% now 'Y' as year %}
- {% include 'snippets/goal_card.html' with year=year %} + {% include 'feed/goal_card.html' with year=year %}
{% endif %} diff --git a/bookwyrm/templates/snippets/goal_card.html b/bookwyrm/templates/feed/goal_card.html similarity index 100% rename from bookwyrm/templates/snippets/goal_card.html rename to bookwyrm/templates/feed/goal_card.html From 6e05fb6dd059c6433b7443a9235cb5822b8a1d2b Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 29 Sep 2021 09:39:23 -0700 Subject: [PATCH 4/5] Use inline form component for goal form on goal page --- bookwyrm/templates/components/inline_form.html | 2 +- bookwyrm/templates/snippets/goal_form.html | 4 ---- bookwyrm/templates/user/goal.html | 17 +++-------------- bookwyrm/templates/user/goal_form.html | 12 ++++++++++++ 4 files changed, 16 insertions(+), 19 deletions(-) create mode 100644 bookwyrm/templates/user/goal_form.html diff --git a/bookwyrm/templates/components/inline_form.html b/bookwyrm/templates/components/inline_form.html index a8924ef2..37f9f556 100644 --- a/bookwyrm/templates/components/inline_form.html +++ b/bookwyrm/templates/components/inline_form.html @@ -1,5 +1,5 @@ {% load i18n %} -