From 3c82230eedab24a6619e85032b096bd1a8f16618 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 2 Oct 2021 19:22:21 -0700 Subject: [PATCH] Load subclasses --- bookwyrm/templates/feed/status.html | 7 ++++--- bookwyrm/templatetags/bookwyrm_tags.py | 20 +++++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/bookwyrm/templates/feed/status.html b/bookwyrm/templates/feed/status.html index 8f354fb8d..5febf4e22 100644 --- a/bookwyrm/templates/feed/status.html +++ b/bookwyrm/templates/feed/status.html @@ -1,5 +1,6 @@ {% extends 'feed/layout.html' %} {% load i18n %} +{% load bookwyrm_tags %} {% block panel %}
@@ -12,13 +13,13 @@
{% for parent in ancestors %} - {% if parent %} + {% if parent.id %}
- {% include 'snippets/status/status.html' with status=parent %} + {% include 'snippets/status/status.html' with status=parent|load_subclass %}
{% endif %} {% endfor %} -
+
{% include 'snippets/status/status.html' with status=status main=True %}
diff --git a/bookwyrm/templatetags/bookwyrm_tags.py b/bookwyrm/templatetags/bookwyrm_tags.py index e683f9c24..2e03c13b4 100644 --- a/bookwyrm/templatetags/bookwyrm_tags.py +++ b/bookwyrm/templatetags/bookwyrm_tags.py @@ -53,18 +53,24 @@ def get_next_shelf(current_shelf): return "to-read" +@register.filter(name="load_subclass") +def load_subclass(status): + """sometimes you didn't select_subclass""" + if hasattr(status, "quotation"): + return status.quotation + if hasattr(status, "review"): + return status.review + if hasattr(status, "comment"): + return status.comment + return status + + @register.simple_tag(takes_context=False) def related_status(notification): """for notifications""" if not notification.related_status: return None - if hasattr(notification.related_status, "quotation"): - return notification.related_status.quotation - if hasattr(notification.related_status, "review"): - return notification.related_status.review - if hasattr(notification.related_status, "comment"): - return notification.related_status.comment - return notification.related_status + return load_subclass(notification.related_status) @register.simple_tag(takes_context=True)