Fixes boost display

This commit is contained in:
Mouse Reeve 2020-04-01 14:55:32 -07:00
parent 8d7ded1c69
commit 29693127ba
6 changed files with 52 additions and 24 deletions

View file

@ -101,6 +101,7 @@ class Boost(Status):
self.status_type = 'Boost' self.status_type = 'Boost'
self.activity_type = 'Announce' self.activity_type = 'Announce'
super().save(*args, **kwargs) super().save(*args, **kwargs)
# This constraint can't work as it would cross tables. # This constraint can't work as it would cross tables.
# class Meta: # class Meta:
# unique_together = ('user', 'boosted_status') # unique_together = ('user', 'boosted_status')

View file

@ -300,8 +300,8 @@ button.warning {
} }
.user-pic { .user-pic {
width: 2rem; width: 2em;
height: 2rem; height: 2em;
border-radius: 50%; border-radius: 50%;
vertical-align: top; vertical-align: top;
position: relative; position: relative;
@ -577,6 +577,14 @@ th, td {
.post .user-pic, .compose-suggestion .user-pic { .post .user-pic, .compose-suggestion .user-pic {
right: 0.25em; right: 0.25em;
} }
.post h2 .subhead {
display: block;
margin-left: 2em;
}
.post .subhead .time-ago {
display: none;
}
.comment-thread .post { .comment-thread .post {
margin-left: 4em; margin-left: 4em;

View file

@ -1,31 +1,22 @@
{% load humanize %}
{% load fr_display %} {% load fr_display %}
<div class="post {{ status.status_type|lower }} depth-{{ depth }} {% if main %}main{% else %}reply{% endif %}">
<div class="post {{ status.status_type | lower }} depth-{{ depth }} {% if main %}main{% else %}reply{% endif %}">
<h2> <h2>
{% include 'snippets/avatar.html' with user=status.user %} {% if status.boosted_status %}
{% include 'snippets/username.html' with user=status.user %} {% include 'snippets/status_header.html' with status=status.boosted_status %}
{% if status.status_type == 'Update' %} <small class="subhead">{% include 'snippets/status_header.html' with status=status %}</small>
{{ status.content | safe }} {% else %}
{% elif status.status_type == 'Review' %} {% include 'snippets/status_header.html' with status=status %}
reviewed {{ status.book.title }} {% endif %}
{% elif status.status_type == 'Comment' %}
commented on {{ status.book.title }}
{% elif status.status_type == 'Boost' %}
boosted
{% elif status.reply_parent %}
{% with parent_status=status|parent %}
replied to {% include 'snippets/username.html' with user=parent_status.user possessive=True %} <a href="{{parent_status.absolute_id }}">{{ parent_status.status_type|lower }}</a>
{% endwith %}
{% endif %}
<span class="time-ago">
<a href="{{ status.absolute_id }}">{{ status.published_date | naturaltime }}</a>
</span>
</h2> </h2>
{% include 'snippets/status_content.html' with status=status %} {% include 'snippets/status_content.html' with status=status %}
</div> </div>
{% if status.status_type != 'Boost' %} {% if status.status_type == 'Boost' %}
{% include 'snippets/interaction.html' with activity=status|boosted_status %}
{% else %}
{% include 'snippets/interaction.html' with activity=status %} {% include 'snippets/interaction.html' with activity=status %}
{% endif %} {% endif %}

View file

@ -30,7 +30,7 @@
<blockquote>{{ status.content | safe }}</blockquote> <blockquote>{{ status.content | safe }}</blockquote>
{% endif %} {% endif %}
{% if status.status_type == 'Boost' %} {% if status.status_type == 'Boost' %}
{% include 'snippets/status.html' with status=status.boosted_status %} {% include 'snippets/status_content.html' with status=status|boosted_status %}
{% endif %} {% endif %}
{% if not max_depth and status.reply_parent or status|replies %}<p><a href="{{ status.absolute_id }}">Thread</a>{% endif %} {% if not max_depth and status.reply_parent or status|replies %}<p><a href="{{ status.absolute_id }}">Thread</a>{% endif %}

View file

@ -0,0 +1,21 @@
{% load humanize %}
{% load fr_display %}
{% include 'snippets/avatar.html' with user=status.user %}
{% include 'snippets/username.html' with user=status.user %}
{% if status.status_type == 'Update' %}
{{ status.content | safe }}
{% elif status.status_type == 'Review' %}
reviewed {{ status.book.title }}
{% elif status.status_type == 'Comment' %}
commented on {{ status.book.title }}
{% elif status.status_type == 'Boost' %}
boosted
{% elif status.reply_parent %}
{% with parent_status=status|parent %}
replied to {% include 'snippets/username.html' with user=parent_status.user possessive=True %} <a href="{{parent_status.absolute_id }}">{{ parent_status.status_type | lower }}</a>
{% endwith %}
{% endif %}
<span class="time-ago">
<a href="{{ status.absolute_id }}">{{ status.published_date | naturaltime }}</a>
</span>

View file

@ -101,6 +101,13 @@ def follow_request_exists(user, requester):
return False return False
@register.filter(name='boosted_status')
def get_boosted(boost):
''' load a boosted status. have to do this or it wont get foregin keys '''
return models.Status.objects.select_subclasses().filter(
id=boost.boosted_status.id
).get()
@register.simple_tag(takes_context=True) @register.simple_tag(takes_context=True)
def shelve_button_identifier(context, book): def shelve_button_identifier(context, book):