mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 10:01:04 +00:00
Load subclasses
This commit is contained in:
parent
c821aaa18e
commit
3c82230eed
2 changed files with 17 additions and 10 deletions
|
@ -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>
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue