From 29693127bad44690b0f9bf090d3cabf4ea0aa147 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 1 Apr 2020 14:55:32 -0700 Subject: [PATCH] Fixes boost display --- fedireads/models/status.py | 1 + fedireads/static/format.css | 12 +++++-- fedireads/templates/snippets/status.html | 33 +++++++------------ .../templates/snippets/status_content.html | 2 +- .../templates/snippets/status_header.html | 21 ++++++++++++ fedireads/templatetags/fr_display.py | 7 ++++ 6 files changed, 52 insertions(+), 24 deletions(-) create mode 100644 fedireads/templates/snippets/status_header.html diff --git a/fedireads/models/status.py b/fedireads/models/status.py index 52068266e..91ec0ab5f 100644 --- a/fedireads/models/status.py +++ b/fedireads/models/status.py @@ -101,6 +101,7 @@ class Boost(Status): self.status_type = 'Boost' self.activity_type = 'Announce' super().save(*args, **kwargs) + # This constraint can't work as it would cross tables. # class Meta: # unique_together = ('user', 'boosted_status') diff --git a/fedireads/static/format.css b/fedireads/static/format.css index 28dc98ac6..9f63ab7fa 100644 --- a/fedireads/static/format.css +++ b/fedireads/static/format.css @@ -300,8 +300,8 @@ button.warning { } .user-pic { - width: 2rem; - height: 2rem; + width: 2em; + height: 2em; border-radius: 50%; vertical-align: top; position: relative; @@ -577,6 +577,14 @@ th, td { .post .user-pic, .compose-suggestion .user-pic { right: 0.25em; } +.post h2 .subhead { + display: block; + margin-left: 2em; +} +.post .subhead .time-ago { + display: none; +} + .comment-thread .post { margin-left: 4em; diff --git a/fedireads/templates/snippets/status.html b/fedireads/templates/snippets/status.html index 89f59fe3f..2ddcbe29c 100644 --- a/fedireads/templates/snippets/status.html +++ b/fedireads/templates/snippets/status.html @@ -1,31 +1,22 @@ -{% 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 %} {{ parent_status.status_type|lower }} - {% endwith %} - {% endif %} - - {{ status.published_date | naturaltime }} - + {% if status.boosted_status %} + {% include 'snippets/status_header.html' with status=status.boosted_status %} + {% include 'snippets/status_header.html' with status=status %} + {% else %} + {% include 'snippets/status_header.html' with status=status %} + {% endif %}

{% include 'snippets/status_content.html' with status=status %}
-{% 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 %} {% endif %} diff --git a/fedireads/templates/snippets/status_content.html b/fedireads/templates/snippets/status_content.html index 7da757845..7029ce9db 100644 --- a/fedireads/templates/snippets/status_content.html +++ b/fedireads/templates/snippets/status_content.html @@ -30,7 +30,7 @@
{{ status.content | safe }}
{% endif %} {% 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 %} {% if not max_depth and status.reply_parent or status|replies %}

Thread{% endif %} diff --git a/fedireads/templates/snippets/status_header.html b/fedireads/templates/snippets/status_header.html new file mode 100644 index 000000000..9650a034f --- /dev/null +++ b/fedireads/templates/snippets/status_header.html @@ -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 %} {{ parent_status.status_type | lower }} + {% endwith %} +{% endif %} + + {{ status.published_date | naturaltime }} + diff --git a/fedireads/templatetags/fr_display.py b/fedireads/templatetags/fr_display.py index 43a84b021..2594441c7 100644 --- a/fedireads/templatetags/fr_display.py +++ b/fedireads/templatetags/fr_display.py @@ -101,6 +101,13 @@ def follow_request_exists(user, requester): 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) def shelve_button_identifier(context, book):