Removes more unused filters

This commit is contained in:
Mouse Reeve 2021-05-11 14:12:28 -07:00
parent f5eb5f982a
commit acd26012be
2 changed files with 2 additions and 54 deletions

View file

@ -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 <em>%s</em>" % (name, obj.book.title)
if name == "comment":
return "%s on <em>%s</em>" % (name, obj.book.title)
if name == "quotation":
return "%s from <em>%s</em>" % (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"""

View file

@ -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 <em>Test Book</em>")
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 <em>Test Book</em>")
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 <em>Test Book</em>")
def test_related_status(self, _):
"""gets the subclass model for a notification status"""
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):