From acd26012bea564850bda7cf9c1b1a67b7be592f1 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 11 May 2021 14:12:28 -0700 Subject: [PATCH] Removes more unused filters --- bookwyrm/templatetags/bookwyrm_tags.py | 31 ++------------------------ bookwyrm/tests/test_templatetags.py | 25 --------------------- 2 files changed, 2 insertions(+), 54 deletions(-) diff --git a/bookwyrm/templatetags/bookwyrm_tags.py b/bookwyrm/templatetags/bookwyrm_tags.py index 81019fe5..c992b9e5 100644 --- a/bookwyrm/templatetags/bookwyrm_tags.py +++ b/bookwyrm/templatetags/bookwyrm_tags.py @@ -81,11 +81,9 @@ def get_user_boosted(user, status): @register.filter(name="boosted_status") def get_boosted(boost): - """load a boosted status. have to do this or it wont get foregin keys""" + """load a boosted status. have to do this or it won't get foreign keys""" return ( - models.Status.objects.select_subclasses() - .filter(id=boost.boosted_status.id) - .get() + models.Status.objects.select_subclasses().get(id=boost.boosted_status.id) ) @@ -118,19 +116,6 @@ def get_mentions(status, user): ) -@register.filter(name="status_preview_name") -def get_status_preview_name(obj): - """text snippet with book context for a status""" - name = obj.__class__.__name__.lower() - if name == "review": - return "%s of %s" % (name, obj.book.title) - if name == "comment": - return "%s on %s" % (name, obj.book.title) - if name == "quotation": - return "%s from %s" % (name, obj.book.title) - return name - - @register.filter(name="next_shelf") def get_next_shelf(current_shelf): """shelf you'd use to update reading progress""" @@ -187,18 +172,6 @@ def latest_read_through(book, user): ) -@register.simple_tag(takes_context=False) -def active_read_through(book, user): - """the most recent read activity""" - return ( - models.ReadThrough.objects.filter( - user=user, book=book, finish_date__isnull=True - ) - .order_by("-start_date") - .first() - ) - - @register.simple_tag(takes_context=False) def comparison_bool(str1, str2): """idk why I need to write a tag for this, it reutrns a bool""" diff --git a/bookwyrm/tests/test_templatetags.py b/bookwyrm/tests/test_templatetags.py index 3e2ecf37..3b782fd5 100644 --- a/bookwyrm/tests/test_templatetags.py +++ b/bookwyrm/tests/test_templatetags.py @@ -157,31 +157,6 @@ class TemplateTags(TestCase): result = bookwyrm_tags.get_mentions(status, self.user) self.assertEqual(result, "@rat@example.com ") - def test_get_status_preview_name(self, _): - """status context string""" - with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"): - status = models.Status.objects.create(content="hi", user=self.user) - result = bookwyrm_tags.get_status_preview_name(status) - self.assertEqual(result, "status") - - status = models.Review.objects.create( - content="hi", user=self.user, book=self.book - ) - result = bookwyrm_tags.get_status_preview_name(status) - self.assertEqual(result, "review of Test Book") - - status = models.Comment.objects.create( - content="hi", user=self.user, book=self.book - ) - result = bookwyrm_tags.get_status_preview_name(status) - self.assertEqual(result, "comment on Test Book") - - status = models.Quotation.objects.create( - content="hi", user=self.user, book=self.book - ) - result = bookwyrm_tags.get_status_preview_name(status) - self.assertEqual(result, "quotation from Test Book") - def test_related_status(self, _): """gets the subclass model for a notification status""" with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):