Load subclasses

This commit is contained in:
Mouse Reeve 2021-10-02 19:22:21 -07:00
parent c821aaa18e
commit 3c82230eed
2 changed files with 17 additions and 10 deletions

View file

@ -1,5 +1,6 @@
{% extends 'feed/layout.html' %} {% extends 'feed/layout.html' %}
{% load i18n %} {% load i18n %}
{% load bookwyrm_tags %}
{% block panel %} {% block panel %}
<header class="block"> <header class="block">
@ -12,13 +13,13 @@
<div class="thread-parent is-relative block"> <div class="thread-parent is-relative block">
<div class="thread"> <div class="thread">
{% for parent in ancestors %} {% for parent in ancestors %}
{% if parent %} {% if parent.id %}
<div class="block"> <div class="block">
{% include 'snippets/status/status.html' with status=parent %} {% include 'snippets/status/status.html' with status=parent|load_subclass %}
</div> </div>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<div class="is-main block"> <div class="is-main block" id="anchor-{{ status.id }}">
{% include 'snippets/status/status.html' with status=status main=True %} {% include 'snippets/status/status.html' with status=status main=True %}
</div> </div>

View file

@ -53,18 +53,24 @@ def get_next_shelf(current_shelf):
return "to-read" 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) @register.simple_tag(takes_context=False)
def related_status(notification): def related_status(notification):
"""for notifications""" """for notifications"""
if not notification.related_status: if not notification.related_status:
return None return None
if hasattr(notification.related_status, "quotation"): return load_subclass(notification.related_status)
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
@register.simple_tag(takes_context=True) @register.simple_tag(takes_context=True)