From 2cca9fab2d880b6f16ae13d2923de89abe239270 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 8 Jan 2022 12:05:42 -0800 Subject: [PATCH 01/28] Cache user relationship for follow buttons --- .../templates/snippets/follow_button.html | 16 +++++++++---- bookwyrm/templatetags/interaction.py | 24 +++++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/bookwyrm/templates/snippets/follow_button.html b/bookwyrm/templates/snippets/follow_button.html index f7025bbaa..0482bde0f 100644 --- a/bookwyrm/templates/snippets/follow_button.html +++ b/bookwyrm/templates/snippets/follow_button.html @@ -1,13 +1,18 @@ {% load i18n %} +{% load interaction %} {% if request.user == user or not request.user.is_authenticated %} -{% elif user in request.user.blocks.all %} +{# nothing to see here -- either it's yourself or your logged out #} +{% else %} + +{% get_relationship user as relationship %} +{% if relationship.is_blocked %} {% include 'snippets/block_button.html' with blocks=True %} {% else %}
- -
{% endif %}
+ +{% endif %} + {% endif %} diff --git a/bookwyrm/templatetags/interaction.py b/bookwyrm/templatetags/interaction.py index 90309aaf9..7aaaaca7e 100644 --- a/bookwyrm/templatetags/interaction.py +++ b/bookwyrm/templatetags/interaction.py @@ -32,3 +32,27 @@ def get_user_boosted(user, status): def get_user_saved_lists(user, book_list): """did the user save a list""" return user.saved_lists.filter(id=book_list.id).exists() + +@register.simple_tag(takes_context=True) +def get_relationship(context, user_object): + """caches the relationship between the logged in user and another user""" + user = context["request"].user + return cache.get(f"relationship-{user.id}-{user_object.id}") or cache.set( + get_relationship_name(user, user_object), + timeout=259200, + ) + +def get_relationship_name(user, user_object): + """returns the relationship type""" + types = { + "is_following": False, + "is_follow_pending": False, + "is_blocked": False, + } + if user_object in user.blocks.all(): + types["is_blocked"] = True + elif user_object in user.following.all(): + types["is_following"] = True + elif user_object in user.follower_requests.all(): + types["is_follow_pending"] = True + return types From f2f40cf3b9a53b3c2a7f4e506880daef8cbd1a84 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 8 Jan 2022 12:59:56 -0800 Subject: [PATCH 02/28] Creates custom get_or_set function --- bookwyrm/templatetags/interaction.py | 26 +++++++++++++++++--------- bookwyrm/utils/cache.py | 10 ++++++++++ 2 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 bookwyrm/utils/cache.py diff --git a/bookwyrm/templatetags/interaction.py b/bookwyrm/templatetags/interaction.py index 7aaaaca7e..c9f08fb31 100644 --- a/bookwyrm/templatetags/interaction.py +++ b/bookwyrm/templatetags/interaction.py @@ -1,8 +1,8 @@ """ template filters for status interaction buttons """ from django import template -from django.core.cache import cache from bookwyrm import models +from bookwyrm.utils.cache import get_or_set register = template.Library() @@ -11,20 +11,23 @@ register = template.Library() @register.filter(name="liked") def get_user_liked(user, status): """did the given user fav a status?""" - return cache.get_or_set( + return get_or_set( f"fav-{user.id}-{status.id}", - models.Favorite.objects.filter(user=user, status=status).exists(), - 259200, + lambda u, s: models.Favorite.objects.filter(user=u, status=s).exists(), + user, + status, + timeout=259200 ) @register.filter(name="boosted") def get_user_boosted(user, status): """did the given user fav a status?""" - return cache.get_or_set( + return get_or_set( f"boost-{user.id}-{status.id}", - status.boosters.filter(user=user).exists(), - 259200, + lambda u: status.boosters.filter(user=u).exists(), + user, + timeout=259200, ) @@ -33,15 +36,20 @@ def get_user_saved_lists(user, book_list): """did the user save a list""" return user.saved_lists.filter(id=book_list.id).exists() + @register.simple_tag(takes_context=True) def get_relationship(context, user_object): """caches the relationship between the logged in user and another user""" user = context["request"].user - return cache.get(f"relationship-{user.id}-{user_object.id}") or cache.set( - get_relationship_name(user, user_object), + return get_or_set( + f"relationship-{user.id}-{user_object.id}", + get_relationship_name, + user, + user_object, timeout=259200, ) + def get_relationship_name(user, user_object): """returns the relationship type""" types = { diff --git a/bookwyrm/utils/cache.py b/bookwyrm/utils/cache.py new file mode 100644 index 000000000..2fca1264a --- /dev/null +++ b/bookwyrm/utils/cache.py @@ -0,0 +1,10 @@ +""" Custom handler for caching """ +from django.core.cache import cache + + +def get_or_set(cache_key, function, *args, timeout=None): + """Django's built-in get_or_set isn't cutting it""" + value = cache.get(cache_key) + if value is None: + cache.set(cache_key, function(*args), timeout=timeout) + return cache.get(cache_key) From c8220485092f8305e9825a84c6d866361a65aa9d Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 8 Jan 2022 13:04:01 -0800 Subject: [PATCH 03/28] Invalidate template cache on relationship change --- bookwyrm/models/relationship.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/bookwyrm/models/relationship.py b/bookwyrm/models/relationship.py index 034174546..2b8f240db 100644 --- a/bookwyrm/models/relationship.py +++ b/bookwyrm/models/relationship.py @@ -1,7 +1,6 @@ """ defines relationships between users """ from django.apps import apps from django.core.cache import cache -from django.core.cache.utils import make_template_fragment_key from django.db import models, transaction, IntegrityError from django.db.models import Q @@ -41,15 +40,10 @@ class UserRelationship(BookWyrmModel): def save(self, *args, **kwargs): """clear the template cache""" # invalidate the template cache - cache_keys = [ - make_template_fragment_key( - "follow_button", [self.user_subject.id, self.user_object.id] - ), - make_template_fragment_key( - "follow_button", [self.user_object.id, self.user_subject.id] - ), - ] - cache.delete_many(cache_keys) + cache.delete_many([ + f"relationship-{self.user_subject.id}-{self.user_object.id}", + f"relationship-{self.user_object.id}-{self.user_subject.id}", + ]) super().save(*args, **kwargs) class Meta: From 82294909a8403e05e1d7b60407230f4ab956a588 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 8 Jan 2022 16:38:52 -0800 Subject: [PATCH 04/28] Python formatting --- bookwyrm/models/readthrough.py | 2 ++ bookwyrm/models/relationship.py | 10 +++--- bookwyrm/templatetags/bookwyrm_tags.py | 45 +++++++++++++------------- bookwyrm/templatetags/interaction.py | 2 +- bookwyrm/views/reading.py | 14 ++++---- 5 files changed, 39 insertions(+), 34 deletions(-) diff --git a/bookwyrm/models/readthrough.py b/bookwyrm/models/readthrough.py index f75918ac1..ceb8e0b6e 100644 --- a/bookwyrm/models/readthrough.py +++ b/bookwyrm/models/readthrough.py @@ -1,5 +1,6 @@ """ progress in a book """ from django.core import validators +from django.core.cache import cache from django.db import models from django.db.models import F, Q @@ -30,6 +31,7 @@ class ReadThrough(BookWyrmModel): def save(self, *args, **kwargs): """update user active time""" + cache.delete(f"latest_read_through-{self.user.id}-{self.book.id}") self.user.update_active_date() # an active readthrough must have an unset finish date if self.finish_date: diff --git a/bookwyrm/models/relationship.py b/bookwyrm/models/relationship.py index 2b8f240db..e95c38fa5 100644 --- a/bookwyrm/models/relationship.py +++ b/bookwyrm/models/relationship.py @@ -40,10 +40,12 @@ class UserRelationship(BookWyrmModel): def save(self, *args, **kwargs): """clear the template cache""" # invalidate the template cache - cache.delete_many([ - f"relationship-{self.user_subject.id}-{self.user_object.id}", - f"relationship-{self.user_object.id}-{self.user_subject.id}", - ]) + cache.delete_many( + [ + f"relationship-{self.user_subject.id}-{self.user_object.id}", + f"relationship-{self.user_object.id}-{self.user_subject.id}", + ] + ) super().save(*args, **kwargs) class Meta: diff --git a/bookwyrm/templatetags/bookwyrm_tags.py b/bookwyrm/templatetags/bookwyrm_tags.py index f173e052c..22f4225b2 100644 --- a/bookwyrm/templatetags/bookwyrm_tags.py +++ b/bookwyrm/templatetags/bookwyrm_tags.py @@ -3,6 +3,7 @@ from django import template from django.db.models import Avg from bookwyrm import models +from bookwyrm.utils import cache from bookwyrm.views.feed import get_suggested_books @@ -79,35 +80,35 @@ def related_status(notification): @register.simple_tag(takes_context=True) def active_shelf(context, book): """check what shelf a user has a book on, if any""" - if hasattr(book, "current_shelves"): - read_shelves = [ - s - for s in book.current_shelves - if s.shelf.identifier in models.Shelf.READ_STATUS_IDENTIFIERS - ] - return read_shelves[0] if len(read_shelves) else {"book": book} - - shelf = ( - models.ShelfBook.objects.filter( - shelf__user=context["request"].user, - book__parent_work__editions=book, + user = context["request"].user + return cache.get_or_set( + f"active_shelf-{user.id}-{book.id}", + lambda u, b: ( + models.ShelfBook.objects.filter( + shelf__user=u, + book__parent_work__editions=b, + ).first() ) - .select_related("book", "shelf") - .first() + or {"book": book}, + user, + book, + timeout=15552000, ) - return shelf if shelf else {"book": book} @register.simple_tag(takes_context=False) def latest_read_through(book, user): """the most recent read activity""" - if hasattr(book, "active_readthroughs"): - return book.active_readthroughs[0] if len(book.active_readthroughs) else None - - return ( - models.ReadThrough.objects.filter(user=user, book=book, is_active=True) - .order_by("-start_date") - .first() + return cache.get_or_set( + f"latest_read_through-{user.id}-{book.id}", + lambda u, b: ( + models.ReadThrough.objects.filter(user=u, book=b, is_active=True) + .order_by("-start_date") + .first() + ), + user, + book, + timeout=15552000, ) diff --git a/bookwyrm/templatetags/interaction.py b/bookwyrm/templatetags/interaction.py index c9f08fb31..89a25420a 100644 --- a/bookwyrm/templatetags/interaction.py +++ b/bookwyrm/templatetags/interaction.py @@ -16,7 +16,7 @@ def get_user_liked(user, status): lambda u, s: models.Favorite.objects.filter(user=u, status=s).exists(), user, status, - timeout=259200 + timeout=259200, ) diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py index c7eda10e1..77e527f39 100644 --- a/bookwyrm/views/reading.py +++ b/bookwyrm/views/reading.py @@ -1,7 +1,6 @@ """ the good stuff! the books! """ from django.contrib.auth.decorators import login_required from django.core.cache import cache -from django.core.cache.utils import make_template_fragment_key from django.db import transaction from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseNotFound from django.shortcuts import get_object_or_404, redirect @@ -46,12 +45,13 @@ class ReadingStatus(View): if not identifier: return HttpResponseBadRequest() - # invalidate the template cache - cache_keys = [ - make_template_fragment_key("shelve_button", [request.user.id, book_id]), - make_template_fragment_key("suggested_books", [request.user.id]), - ] - cache.delete_many(cache_keys) + # invalidate related caches + cache.delete_many( + [ + f"suggested_books-{request.user.id}", + f"active_shelf-{request.user.id}-{book_id}", + ] + ) desired_shelf = get_object_or_404( models.Shelf, identifier=identifier, user=request.user From 593d1638f969f0d872676a2ce3f294444896bc87 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 9 Jan 2022 12:04:45 -0800 Subject: [PATCH 05/28] Updates tests env --- pytest.ini | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pytest.ini b/pytest.ini index 9ef72449c..c5cdc35d1 100644 --- a/pytest.ini +++ b/pytest.ini @@ -6,13 +6,18 @@ markers = integration: marks tests as requiring external resources (deselect with '-m "not integration"') env = + SECRET_KEY = beepbeep DEBUG = false - USE_HTTPS=true + USE_HTTPS = true DOMAIN = your.domain.here BOOKWYRM_DATABASE_BACKEND = postgres MEDIA_ROOT = images/ CELERY_BROKER = "" REDIS_BROKER_PORT = 6379 + REDIS_BROKER_PASSWORD = beep + REDIS_ACTIVITY_PORT = 6379 + REDIS_ACTIVITY_PASSWORD = beep + USE_DUMMY_CACHE = true FLOWER_PORT = 8888 EMAIL_HOST = "smtp.mailgun.org" EMAIL_PORT = 587 @@ -20,4 +25,3 @@ env = EMAIL_HOST_PASSWORD = "" EMAIL_USE_TLS = true ENABLE_PREVIEW_IMAGES = false - USE_S3 = false From 556c9ea98fc8d7fd8e3c1afeab68cc3ee164a846 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 9 Jan 2022 12:16:01 -0800 Subject: [PATCH 06/28] Adjusts cache get_or_set to work with tests --- bookwyrm/utils/cache.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bookwyrm/utils/cache.py b/bookwyrm/utils/cache.py index 2fca1264a..aebb8e754 100644 --- a/bookwyrm/utils/cache.py +++ b/bookwyrm/utils/cache.py @@ -6,5 +6,6 @@ def get_or_set(cache_key, function, *args, timeout=None): """Django's built-in get_or_set isn't cutting it""" value = cache.get(cache_key) if value is None: - cache.set(cache_key, function(*args), timeout=timeout) - return cache.get(cache_key) + value = function(*args) + cache.set(cache_key, value, timeout=timeout) + return value From e8c830750a92c70f1bfca02caeceebc889d990d3 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 9 Jan 2022 13:00:02 -0800 Subject: [PATCH 07/28] No cache for suggested books --- bookwyrm/templates/landing/landing.html | 3 ++- bookwyrm/views/reading.py | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/bookwyrm/templates/landing/landing.html b/bookwyrm/templates/landing/landing.html index 759e8c619..985a7c6db 100644 --- a/bookwyrm/templates/landing/landing.html +++ b/bookwyrm/templates/landing/landing.html @@ -7,7 +7,8 @@

{% trans "Recent Books" %}

-{% cache 60 * 60 %} +{% get_current_language as LANGUAGE_CODE %} +{% cache 60 * 60 LANGUAGE_CODE %}
diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py index 77e527f39..fd12dc0fe 100644 --- a/bookwyrm/views/reading.py +++ b/bookwyrm/views/reading.py @@ -46,11 +46,8 @@ class ReadingStatus(View): return HttpResponseBadRequest() # invalidate related caches - cache.delete_many( - [ - f"suggested_books-{request.user.id}", - f"active_shelf-{request.user.id}-{book_id}", - ] + cache.delete( + f"active_shelf-{request.user.id}-{book_id}", ) desired_shelf = get_object_or_404( From 0a182e81509694910d0d9aa3dde1cf3717f6a130 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 9 Jan 2022 13:04:41 -0800 Subject: [PATCH 08/28] Caches query for landing page books --- bookwyrm/templates/landing/landing.html | 3 +++ bookwyrm/templatetags/bookwyrm_tags.py | 18 ++++++++++++++++++ bookwyrm/views/admin/invite.py | 2 -- bookwyrm/views/helpers.py | 18 ------------------ bookwyrm/views/landing/landing.py | 2 -- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/bookwyrm/templates/landing/landing.html b/bookwyrm/templates/landing/landing.html index 985a7c6db..c37717597 100644 --- a/bookwyrm/templates/landing/landing.html +++ b/bookwyrm/templates/landing/landing.html @@ -1,6 +1,8 @@ {% extends 'landing/layout.html' %} {% load i18n %} {% load cache %} +{% load bookwyrm_tags %} + {% block panel %}
@@ -9,6 +11,7 @@ {% get_current_language as LANGUAGE_CODE %} {% cache 60 * 60 LANGUAGE_CODE %} +{% get_landing_books as books %}
diff --git a/bookwyrm/templatetags/bookwyrm_tags.py b/bookwyrm/templatetags/bookwyrm_tags.py index 22f4225b2..68ba747dd 100644 --- a/bookwyrm/templatetags/bookwyrm_tags.py +++ b/bookwyrm/templatetags/bookwyrm_tags.py @@ -112,6 +112,24 @@ def latest_read_through(book, user): ) +@register.simple_tag(takes_context=False) +def get_landing_books(): + """list of books for the landing page""" + return list( + set( + models.Edition.objects.filter( + review__published_date__isnull=False, + review__deleted=False, + review__user__local=True, + review__privacy__in=["public", "unlisted"], + ) + .exclude(cover__exact="") + .distinct() + .order_by("-review__published_date")[:6] + ) + ) + + @register.simple_tag(takes_context=True) def mutuals_count(context, user): """how many users that you follow, follow them""" diff --git a/bookwyrm/views/admin/invite.py b/bookwyrm/views/admin/invite.py index 8fd68b705..322c5fcba 100644 --- a/bookwyrm/views/admin/invite.py +++ b/bookwyrm/views/admin/invite.py @@ -16,7 +16,6 @@ from django.views.decorators.http import require_POST from bookwyrm import emailing, forms, models from bookwyrm.settings import PAGE_LENGTH -from bookwyrm.views import helpers # pylint: disable= no-self-use @@ -174,7 +173,6 @@ class InviteRequest(View): data = { "request_form": form, "request_received": received, - "books": helpers.get_landing_books(), } return TemplateResponse(request, "landing/landing.html", data) diff --git a/bookwyrm/views/helpers.py b/bookwyrm/views/helpers.py index 8cc0aea81..74d867b66 100644 --- a/bookwyrm/views/helpers.py +++ b/bookwyrm/views/helpers.py @@ -153,24 +153,6 @@ def is_blocked(viewer, user): return False -def get_landing_books(): - """list of books for the landing page""" - - return list( - set( - models.Edition.objects.filter( - review__published_date__isnull=False, - review__deleted=False, - review__user__local=True, - review__privacy__in=["public", "unlisted"], - ) - .exclude(cover__exact="") - .distinct() - .order_by("-review__published_date")[:6] - ) - ) - - def load_date_in_user_tz_as_utc(date_str: str, user: models.User) -> datetime: """ensures that data is stored consistently in the UTC timezone""" if not date_str: diff --git a/bookwyrm/views/landing/landing.py b/bookwyrm/views/landing/landing.py index c8bba0664..4e9aba58a 100644 --- a/bookwyrm/views/landing/landing.py +++ b/bookwyrm/views/landing/landing.py @@ -3,7 +3,6 @@ from django.template.response import TemplateResponse from django.views import View from bookwyrm import forms -from bookwyrm.views import helpers from bookwyrm.views.feed import Feed @@ -36,6 +35,5 @@ class Landing(View): data = { "register_form": forms.RegisterForm(), "request_form": forms.InviteRequestForm(), - "books": helpers.get_landing_books(), } return TemplateResponse(request, "landing/landing.html", data) From 4faf3cf09ac0e86545df94870e5f1b6aedbc9d4d Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 11 Jan 2022 09:12:04 -0800 Subject: [PATCH 09/28] Fixes button on search page --- bookwyrm/templates/search/book.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bookwyrm/templates/search/book.html b/bookwyrm/templates/search/book.html index 0ce436767..ab62d4734 100644 --- a/bookwyrm/templates/search/book.html +++ b/bookwyrm/templates/search/book.html @@ -75,9 +75,11 @@ {% csrf_token %} - +
+ +
From 048460aec29c472b4a83e2b2e18d569f2b74a2d5 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 11 Jan 2022 09:12:17 -0800 Subject: [PATCH 10/28] Don't show filters notice on paged feed --- bookwyrm/templates/snippets/filters_panel/filters_panel.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bookwyrm/templates/snippets/filters_panel/filters_panel.html b/bookwyrm/templates/snippets/filters_panel/filters_panel.html index 80e868926..84b271633 100644 --- a/bookwyrm/templates/snippets/filters_panel/filters_panel.html +++ b/bookwyrm/templates/snippets/filters_panel/filters_panel.html @@ -3,16 +3,15 @@ {% trans "Filters" %} - {% if filters_applied %} - {{ _("Filters are applied") }} + {% trans "Filters are applied" %} {% endif %} - {% if request.GET %} + {% if method != "post" and request.GET %} {% trans "Filters are applied" %} From 0d2c6e63d18f591678c1ffc697b43fac69a324a0 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 11 Jan 2022 09:50:04 -0800 Subject: [PATCH 11/28] 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 %} +
- {% include "book/add_readthrough_modal.html" with id="add-readthrough" %} + {% include "readthrough/add_readthrough_modal.html" with id="add-readthrough" %} {% if not readthroughs.exists %}

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

{% endif %} {% for readthrough in readthroughs %} - {% include 'book/readthrough.html' with readthrough=readthrough %} + {% include 'readthrough/readthrough_list.html' with readthrough=readthrough %} {% endfor %}
diff --git a/bookwyrm/templates/book/add_readthrough_modal.html b/bookwyrm/templates/readthrough/add_readthrough_modal.html similarity index 90% rename from bookwyrm/templates/book/add_readthrough_modal.html rename to bookwyrm/templates/readthrough/add_readthrough_modal.html index 45cbb2aa5..55d2198ce 100644 --- a/bookwyrm/templates/book/add_readthrough_modal.html +++ b/bookwyrm/templates/readthrough/add_readthrough_modal.html @@ -13,7 +13,7 @@ Add read dates for "{{ title }}" {% endblock %} {% block modal-body %} -{% include 'snippets/readthrough_form.html' with readthrough=None %} +{% include 'readthrough/readthrough_form.html' with readthrough=None %} {% endblock %} {% block modal-footer %} diff --git a/bookwyrm/templates/book/delete_readthrough_modal.html b/bookwyrm/templates/readthrough/delete_readthrough_modal.html similarity index 100% rename from bookwyrm/templates/book/delete_readthrough_modal.html rename to bookwyrm/templates/readthrough/delete_readthrough_modal.html diff --git a/bookwyrm/templates/snippets/readthrough_form.html b/bookwyrm/templates/readthrough/readthrough_form.html similarity index 100% rename from bookwyrm/templates/snippets/readthrough_form.html rename to bookwyrm/templates/readthrough/readthrough_form.html diff --git a/bookwyrm/templates/book/readthrough.html b/bookwyrm/templates/readthrough/readthrough_list.html similarity index 96% rename from bookwyrm/templates/book/readthrough.html rename to bookwyrm/templates/readthrough/readthrough_list.html index e711ecd00..21ce557cc 100644 --- a/bookwyrm/templates/book/readthrough.html +++ b/bookwyrm/templates/readthrough/readthrough_list.html @@ -77,7 +77,7 @@ - {% include "readthrough/add_readthrough_modal.html" with id="add-readthrough" %} + {% include "readthrough/readthrough_modal.html" with id="add-readthrough" %} {% if not readthroughs.exists %}

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

diff --git a/bookwyrm/templates/readthrough/readthrough.html b/bookwyrm/templates/readthrough/readthrough.html index efd776834..bed59d29b 100644 --- a/bookwyrm/templates/readthrough/readthrough.html +++ b/bookwyrm/templates/readthrough/readthrough.html @@ -10,6 +10,6 @@ Add read dates for "{{ title }}" {% block content %} -{% include "readthrough/add_readthrough_modal.html" with book=book active=True static=True %} +{% include "readthrough/readthrough_modal.html" with book=book active=True static=True %} {% endblock %} diff --git a/bookwyrm/templates/readthrough/readthrough_list.html b/bookwyrm/templates/readthrough/readthrough_list.html index 21ce557cc..9f9db9a55 100644 --- a/bookwyrm/templates/readthrough/readthrough_list.html +++ b/bookwyrm/templates/readthrough/readthrough_list.html @@ -3,7 +3,7 @@ {% load tz %} {% load utilities %}
-
+
{% trans "Progress Updates:" %} @@ -58,7 +58,11 @@
{% trans "Edit read dates" as button_text %} - {% include 'snippets/toggle/toggle_button.html' with class="is-small" text=button_text icon="pencil" controls_text="edit_readthrough" controls_uid=readthrough.id focus="edit_readthrough" %} +
{% trans "Delete these read dates" as button_text %} @@ -74,16 +78,7 @@
- -{% join "delete_readthrough" readthrough.id as modal_id %} -{% include 'readthrough/delete_readthrough_modal.html' with id=modal_id %} +{% join "edit_readthrough" readthrough.id as edit_modal_id %} +{% include "readthrough/readthrough_modal.html" with readthrough=readthrough id=edit_modal_id %} +{% join "delete_readthrough" readthrough.id as delete_modal_id %} +{% include 'readthrough/delete_readthrough_modal.html' with id=delete_modal_id %} diff --git a/bookwyrm/templates/readthrough/add_readthrough_modal.html b/bookwyrm/templates/readthrough/readthrough_modal.html similarity index 100% rename from bookwyrm/templates/readthrough/add_readthrough_modal.html rename to bookwyrm/templates/readthrough/readthrough_modal.html From a412f87c641781e7fd671aabe962aaa8fa3f31d9 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 11 Jan 2022 10:29:11 -0800 Subject: [PATCH 15/28] Match wording to state --- .../templates/readthrough/readthrough_modal.html | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/readthrough/readthrough_modal.html b/bookwyrm/templates/readthrough/readthrough_modal.html index e177850e2..67a3b6201 100644 --- a/bookwyrm/templates/readthrough/readthrough_modal.html +++ b/bookwyrm/templates/readthrough/readthrough_modal.html @@ -3,9 +3,17 @@ {% load utilities %} {% block modal-title %} + +{% if readthrough %} {% blocktrans trimmed with title=book|book_title %} -Add read dates for "{{ title }}" + Update read dates for "{{ title }}" {% endblocktrans %} +{% else %} +{% blocktrans trimmed with title=book|book_title %} + Add read dates for "{{ title }}" +{% endblocktrans %} +{% endif %} + {% endblock %} {% block modal-form-open %} @@ -61,7 +69,7 @@ Add read dates for "{{ title }}" {% endblock %} {% block modal-footer %} - + {% if not static %} {% endif %} From 68d943fb26987388a0a41885a63227b3dfabff64 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 11 Jan 2022 10:33:58 -0800 Subject: [PATCH 16/28] Preserve readthrough id in edit --- bookwyrm/templates/readthrough/readthrough.html | 2 +- bookwyrm/views/reading.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/readthrough/readthrough.html b/bookwyrm/templates/readthrough/readthrough.html index bed59d29b..0b42017e6 100644 --- a/bookwyrm/templates/readthrough/readthrough.html +++ b/bookwyrm/templates/readthrough/readthrough.html @@ -4,7 +4,7 @@ {% block title %} {% blocktrans trimmed with title=book|book_title %} -Add read dates for "{{ title }}" +Update read dates for "{{ title }}" {% endblocktrans %} {% endblock %} diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py index 7c2b6d0bd..22ee450ad 100644 --- a/bookwyrm/views/reading.py +++ b/bookwyrm/views/reading.py @@ -137,6 +137,10 @@ class CreateReadThrough(View): if not form.is_valid(): book = get_object_or_404(models.Edition, id=book_id) data = {"form": form, "book": book} + if request.POST.get("id"): + data["readthrough"] = get_object_or_404( + models.ReadThrough, id=request.POST.get("id") + ) return TemplateResponse( request, "readthrough/readthrough.html", data ) @@ -144,7 +148,6 @@ class CreateReadThrough(View): return redirect("book", book_id) - @transaction.atomic def update_readthrough_on_shelve( user, annotated_book, status, start_date=None, finish_date=None From 4ca90ca10f49602f98d7eb07227345925811f20b Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 11 Jan 2022 10:40:32 -0800 Subject: [PATCH 17/28] Renames class view --- bookwyrm/forms.py | 1 + bookwyrm/urls.py | 2 +- bookwyrm/views/__init__.py | 2 +- bookwyrm/views/reading.py | 12 ++++++++++-- bookwyrm/views/status.py | 1 + 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index 83f0d0534..b9ff59c2e 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -479,6 +479,7 @@ class SortListForm(forms.Form): ), ) + class ReadThroughForm(CustomForm): def clean(self): """make sure the email isn't in use by a registered user""" diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index f0851df2b..ae67c0920 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -457,7 +457,7 @@ urlpatterns = [ # reading progress re_path(r"^edit-readthrough/?$", views.edit_readthrough, name="edit-readthrough"), re_path(r"^delete-readthrough/?$", views.delete_readthrough), - re_path(r"^create-readthrough/?$", views.CreateReadThrough.as_view(), name="create-readthrough"), + re_path(r"^create-readthrough/?$", views.ReadThrough.as_view(), name="create-readthrough"), re_path(r"^delete-progressupdate/?$", views.delete_progressupdate), # shelve actions re_path( diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index 092d27a6b..4157e75b9 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -88,7 +88,7 @@ from .list import Lists, SavedLists, List, Curate, UserLists from .list import save_list, unsave_list, delete_list, unsafe_embed_list from .notifications import Notifications from .outbox import Outbox -from .reading import CreateReadThrough, delete_readthrough, delete_progressupdate +from .reading import ReadThrough, delete_readthrough, delete_progressupdate from .reading import ReadingStatus from .rss_feed import RssFeed from .search import Search diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py index 22ee450ad..a5d69947e 100644 --- a/bookwyrm/views/reading.py +++ b/bookwyrm/views/reading.py @@ -116,10 +116,18 @@ class ReadingStatus(View): @method_decorator(login_required, name="dispatch") -class CreateReadThrough(View): +class ReadThrough(View): """Add new read dates""" - def get(self, request): + def get(self, request, book_id, readthrough_id=None): """standalone form in case of errors""" + book = get_object_or_404(models.Edition, id=book_id) + form = forms.ReadThroughForm() + data = {"form": form, "book": book} + if readthrough_id: + data["readthrough"] = get_object_or_404( + models.ReadThrough, id=readthrough_id + ) + return TemplateResponse(request, "readthrough/readthrough.html", data) def post(self, request): diff --git a/bookwyrm/views/status.py b/bookwyrm/views/status.py index bb69d30c0..5dc8e8fa0 100644 --- a/bookwyrm/views/status.py +++ b/bookwyrm/views/status.py @@ -159,6 +159,7 @@ def update_progress(request, book_id): # pylint: disable=unused-argument @require_POST def edit_readthrough(request): """can't use the form because the dates are too finnicky""" + # TODO: remove this, it duplicates the code in the ReadThrough view readthrough = get_object_or_404(models.ReadThrough, id=request.POST.get("id")) readthrough.raise_not_editable(request.user) From 0f9881365b4f0c150fb0d75f60ce5bc6354fd494 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 11 Jan 2022 10:41:33 -0800 Subject: [PATCH 18/28] Python formatting --- bookwyrm/urls.py | 6 +++++- bookwyrm/views/reading.py | 7 +++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index ae67c0920..7a95103df 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -457,7 +457,11 @@ urlpatterns = [ # reading progress re_path(r"^edit-readthrough/?$", views.edit_readthrough, name="edit-readthrough"), re_path(r"^delete-readthrough/?$", views.delete_readthrough), - re_path(r"^create-readthrough/?$", views.ReadThrough.as_view(), name="create-readthrough"), + re_path( + r"^create-readthrough/?$", + views.ReadThrough.as_view(), + name="create-readthrough", + ), re_path(r"^delete-progressupdate/?$", views.delete_progressupdate), # shelve actions re_path( diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py index a5d69947e..d90c0e9dc 100644 --- a/bookwyrm/views/reading.py +++ b/bookwyrm/views/reading.py @@ -118,6 +118,7 @@ class ReadingStatus(View): @method_decorator(login_required, name="dispatch") class ReadThrough(View): """Add new read dates""" + def get(self, request, book_id, readthrough_id=None): """standalone form in case of errors""" book = get_object_or_404(models.Edition, id=book_id) @@ -129,7 +130,6 @@ class ReadThrough(View): ) return TemplateResponse(request, "readthrough/readthrough.html", data) - def post(self, request): """can't use the form normally because the dates are too finnicky""" book_id = request.POST.get("book") @@ -149,9 +149,7 @@ class ReadThrough(View): data["readthrough"] = get_object_or_404( models.ReadThrough, id=request.POST.get("id") ) - return TemplateResponse( - request, "readthrough/readthrough.html", data - ) + return TemplateResponse(request, "readthrough/readthrough.html", data) form.save() return redirect("book", book_id) @@ -196,6 +194,7 @@ def delete_readthrough(request): readthrough.delete() return redirect(request.headers.get("Referer", "/")) + @login_required @require_POST def delete_progressupdate(request): From 834eb95d9d02a74fd3c2a107e004e4eb415ad35f Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 11 Jan 2022 10:43:17 -0800 Subject: [PATCH 19/28] Reformats readthrough view test --- bookwyrm/tests/views/test_readthrough.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/bookwyrm/tests/views/test_readthrough.py b/bookwyrm/tests/views/test_readthrough.py index 6697c0e07..f4ca3af61 100644 --- a/bookwyrm/tests/views/test_readthrough.py +++ b/bookwyrm/tests/views/test_readthrough.py @@ -41,10 +41,8 @@ class ReadThrough(TestCase): self.assertEqual(self.edition.readthrough_set.count(), 0) self.client.post( - "/reading-status/start/{}".format(self.edition.id), - { - "start_date": "2020-11-27", - }, + f"/reading-status/start/{self.edition.id}", + {"start_date": "2020-11-27"}, ) readthroughs = self.edition.readthrough_set.all() @@ -62,10 +60,8 @@ class ReadThrough(TestCase): self.assertEqual(self.edition.readthrough_set.count(), 0) self.client.post( - "/reading-status/start/{}".format(self.edition.id), - { - "start_date": "2020-11-27", - }, + f"/reading-status/start/{self.edition.id}", + {"start_date": "2020-11-27"}, ) readthroughs = self.edition.readthrough_set.all() From 9fdb75e2d3e338b33f1caf962b9d2025aa898303 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 11 Jan 2022 10:47:55 -0800 Subject: [PATCH 20/28] Renames item layout file --- bookwyrm/templates/notifications/items/accept.html | 2 +- bookwyrm/templates/notifications/items/add.html | 2 +- bookwyrm/templates/notifications/items/boost.html | 2 +- bookwyrm/templates/notifications/items/fav.html | 2 +- bookwyrm/templates/notifications/items/follow.html | 2 +- bookwyrm/templates/notifications/items/follow_request.html | 2 +- bookwyrm/templates/notifications/items/import.html | 2 +- bookwyrm/templates/notifications/items/invite.html | 2 +- bookwyrm/templates/notifications/items/join.html | 2 +- .../notifications/items/{item_layout.html => layout.html} | 0 bookwyrm/templates/notifications/items/leave.html | 2 +- bookwyrm/templates/notifications/items/mention.html | 2 +- bookwyrm/templates/notifications/items/remove.html | 2 +- bookwyrm/templates/notifications/items/reply.html | 2 +- bookwyrm/templates/notifications/items/report.html | 2 +- bookwyrm/templates/notifications/items/update.html | 2 +- 16 files changed, 15 insertions(+), 15 deletions(-) rename bookwyrm/templates/notifications/items/{item_layout.html => layout.html} (100%) diff --git a/bookwyrm/templates/notifications/items/accept.html b/bookwyrm/templates/notifications/items/accept.html index 045e23266..5f26008f4 100644 --- a/bookwyrm/templates/notifications/items/accept.html +++ b/bookwyrm/templates/notifications/items/accept.html @@ -1,4 +1,4 @@ -{% extends 'notifications/items/item_layout.html' %} +{% extends 'notifications/items/layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/items/add.html b/bookwyrm/templates/notifications/items/add.html index 0e653aeb8..6a0183ebe 100644 --- a/bookwyrm/templates/notifications/items/add.html +++ b/bookwyrm/templates/notifications/items/add.html @@ -1,4 +1,4 @@ -{% extends 'notifications/items/item_layout.html' %} +{% extends 'notifications/items/layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/items/boost.html b/bookwyrm/templates/notifications/items/boost.html index 5f8962b38..6bb373ef6 100644 --- a/bookwyrm/templates/notifications/items/boost.html +++ b/bookwyrm/templates/notifications/items/boost.html @@ -1,4 +1,4 @@ -{% extends 'notifications/items/item_layout.html' %} +{% extends 'notifications/items/layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/items/fav.html b/bookwyrm/templates/notifications/items/fav.html index fbb865e4f..58964d033 100644 --- a/bookwyrm/templates/notifications/items/fav.html +++ b/bookwyrm/templates/notifications/items/fav.html @@ -1,4 +1,4 @@ -{% extends 'notifications/items/item_layout.html' %} +{% extends 'notifications/items/layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/items/follow.html b/bookwyrm/templates/notifications/items/follow.html index 7220d5d17..3518e7b1b 100644 --- a/bookwyrm/templates/notifications/items/follow.html +++ b/bookwyrm/templates/notifications/items/follow.html @@ -1,4 +1,4 @@ -{% extends 'notifications/items/item_layout.html' %} +{% extends 'notifications/items/layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/items/follow_request.html b/bookwyrm/templates/notifications/items/follow_request.html index febb0a50e..9cec8116a 100644 --- a/bookwyrm/templates/notifications/items/follow_request.html +++ b/bookwyrm/templates/notifications/items/follow_request.html @@ -1,4 +1,4 @@ -{% extends 'notifications/items/item_layout.html' %} +{% extends 'notifications/items/layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/items/import.html b/bookwyrm/templates/notifications/items/import.html index f3c8b5c09..7f5994811 100644 --- a/bookwyrm/templates/notifications/items/import.html +++ b/bookwyrm/templates/notifications/items/import.html @@ -1,4 +1,4 @@ -{% extends 'notifications/items/item_layout.html' %} +{% extends 'notifications/items/layout.html' %} {% load i18n %} {% block primary_link %}{% spaceless %} diff --git a/bookwyrm/templates/notifications/items/invite.html b/bookwyrm/templates/notifications/items/invite.html index abb8cd02f..aff416b07 100644 --- a/bookwyrm/templates/notifications/items/invite.html +++ b/bookwyrm/templates/notifications/items/invite.html @@ -1,4 +1,4 @@ -{% extends 'notifications/items/item_layout.html' %} +{% extends 'notifications/items/layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/items/join.html b/bookwyrm/templates/notifications/items/join.html index c10def456..82f8a8c50 100644 --- a/bookwyrm/templates/notifications/items/join.html +++ b/bookwyrm/templates/notifications/items/join.html @@ -1,4 +1,4 @@ -{% extends 'notifications/items/item_layout.html' %} +{% extends 'notifications/items/layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/items/item_layout.html b/bookwyrm/templates/notifications/items/layout.html similarity index 100% rename from bookwyrm/templates/notifications/items/item_layout.html rename to bookwyrm/templates/notifications/items/layout.html diff --git a/bookwyrm/templates/notifications/items/leave.html b/bookwyrm/templates/notifications/items/leave.html index 422a31dea..c17a1986e 100644 --- a/bookwyrm/templates/notifications/items/leave.html +++ b/bookwyrm/templates/notifications/items/leave.html @@ -1,4 +1,4 @@ -{% extends 'notifications/items/item_layout.html' %} +{% extends 'notifications/items/layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/items/mention.html b/bookwyrm/templates/notifications/items/mention.html index cda77163e..ead3c8a6c 100644 --- a/bookwyrm/templates/notifications/items/mention.html +++ b/bookwyrm/templates/notifications/items/mention.html @@ -1,4 +1,4 @@ -{% extends 'notifications/items/item_layout.html' %} +{% extends 'notifications/items/layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/items/remove.html b/bookwyrm/templates/notifications/items/remove.html index eba18fd89..84160c7bd 100644 --- a/bookwyrm/templates/notifications/items/remove.html +++ b/bookwyrm/templates/notifications/items/remove.html @@ -1,4 +1,4 @@ -{% extends 'notifications/items/item_layout.html' %} +{% extends 'notifications/items/layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/items/reply.html b/bookwyrm/templates/notifications/items/reply.html index 883bbbb5b..0aa664ce4 100644 --- a/bookwyrm/templates/notifications/items/reply.html +++ b/bookwyrm/templates/notifications/items/reply.html @@ -1,4 +1,4 @@ -{% extends 'notifications/items/item_layout.html' %} +{% extends 'notifications/items/layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/items/report.html b/bookwyrm/templates/notifications/items/report.html index f537b5255..fdd5f0094 100644 --- a/bookwyrm/templates/notifications/items/report.html +++ b/bookwyrm/templates/notifications/items/report.html @@ -1,4 +1,4 @@ -{% extends 'notifications/items/item_layout.html' %} +{% extends 'notifications/items/layout.html' %} {% load i18n %} diff --git a/bookwyrm/templates/notifications/items/update.html b/bookwyrm/templates/notifications/items/update.html index be796b785..7fc52cef1 100644 --- a/bookwyrm/templates/notifications/items/update.html +++ b/bookwyrm/templates/notifications/items/update.html @@ -1,4 +1,4 @@ -{% extends 'notifications/items/item_layout.html' %} +{% extends 'notifications/items/layout.html' %} {% load i18n %} {% load utilities %} From 0d7801f6f4b4b40154d0cb06ad22b00e3a72040b Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 11 Jan 2022 11:04:56 -0800 Subject: [PATCH 21/28] Show unread notifications color --- bookwyrm/settings.py | 2 +- bookwyrm/static/css/bookwyrm.css | 7 +++++++ bookwyrm/templates/notifications/items/layout.html | 8 ++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py index fe2f7467a..92ff7ecdd 100644 --- a/bookwyrm/settings.py +++ b/bookwyrm/settings.py @@ -14,7 +14,7 @@ VERSION = "0.1.1" PAGE_LENGTH = env("PAGE_LENGTH", 15) DEFAULT_LANGUAGE = env("DEFAULT_LANGUAGE", "English") -JS_CACHE = "2d3181e1" +JS_CACHE = "9b4cc1f7" # email EMAIL_BACKEND = env("EMAIL_BACKEND", "django.core.mail.backends.smtp.EmailBackend") diff --git a/bookwyrm/static/css/bookwyrm.css b/bookwyrm/static/css/bookwyrm.css index 4d960734e..cc87e5b81 100644 --- a/bookwyrm/static/css/bookwyrm.css +++ b/bookwyrm/static/css/bookwyrm.css @@ -751,6 +751,13 @@ ol.ordered-list li::before { padding: 0 0.75em; } +/* Notifications page + ******************************************************************************/ + +.notification a.icon { + text-decoration: none !important; +} + /* Breadcrumbs ******************************************************************************/ diff --git a/bookwyrm/templates/notifications/items/layout.html b/bookwyrm/templates/notifications/items/layout.html index 506bda8dd..6ddbdcc31 100644 --- a/bookwyrm/templates/notifications/items/layout.html +++ b/bookwyrm/templates/notifications/items/layout.html @@ -1,9 +1,9 @@ {% load bookwyrm_tags %} {% related_status notification as related_status %} -
-
-
- +
+
+ From c12aa1ef798cf0c6305efc80354c26ac27a3802f Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 11 Jan 2022 11:38:26 -0800 Subject: [PATCH 22/28] Fixes test --- bookwyrm/tests/views/test_reading.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bookwyrm/tests/views/test_reading.py b/bookwyrm/tests/views/test_reading.py index 0d6c13aa3..759866947 100644 --- a/bookwyrm/tests/views/test_reading.py +++ b/bookwyrm/tests/views/test_reading.py @@ -231,11 +231,12 @@ class ReadingViews(TestCase): "finish_date": "2018-03-07", "book": self.book.id, "id": "", + "user": self.local_user.id, }, ) request.user = self.local_user - views.create_readthrough(request) + views.ReadThrough.as_view()(request) readthrough = models.ReadThrough.objects.get() self.assertEqual(readthrough.start_date.year, 2017) self.assertEqual(readthrough.start_date.month, 1) From f4b655f952494a2fc2c4f82eb828a0e4b4ca789b Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 11 Jan 2022 11:45:37 -0800 Subject: [PATCH 23/28] Makes form names unique in readthrough modal --- bookwyrm/templates/readthrough/readthrough_modal.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/templates/readthrough/readthrough_modal.html b/bookwyrm/templates/readthrough/readthrough_modal.html index 67a3b6201..07d27b664 100644 --- a/bookwyrm/templates/readthrough/readthrough_modal.html +++ b/bookwyrm/templates/readthrough/readthrough_modal.html @@ -17,7 +17,7 @@ {% endblock %} {% block modal-form-open %} -
+ {% endblock %} {% block modal-body %} From 150756dbd050bd60a95205fa69fdd9e25ced98f1 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 11 Jan 2022 12:03:04 -0800 Subject: [PATCH 24/28] Adds breadcrumbs to shelf page --- bookwyrm/templates/shelf/shelf.html | 21 +++++++++++-------- .../snippets/translated_shelf_name.html | 12 +++++++++++ 2 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 bookwyrm/templates/snippets/translated_shelf_name.html diff --git a/bookwyrm/templates/shelf/shelf.html b/bookwyrm/templates/shelf/shelf.html index 0184ab1d8..0e295a873 100644 --- a/bookwyrm/templates/shelf/shelf.html +++ b/bookwyrm/templates/shelf/shelf.html @@ -19,6 +19,17 @@ + +