forked from mirrors/bookwyrm
Cleans up notifications
This commit is contained in:
parent
a7fe3fed75
commit
03a5f333e1
2 changed files with 91 additions and 43 deletions
|
@ -13,57 +13,81 @@
|
||||||
|
|
||||||
<div class="block">
|
<div class="block">
|
||||||
{% for notification in notifications %}
|
{% for notification in notifications %}
|
||||||
|
{% related_status notification as related_status %}
|
||||||
<div class="notification {% if notification.id in unread %} is-primary{% endif %}">
|
<div class="notification {% if notification.id in unread %} is-primary{% endif %}">
|
||||||
<div class="block">
|
<div class="columns is-mobile">
|
||||||
<p>
|
<div class="column is-narrow is-size-3 {% if notification.id in unread%}has-text-white{% else %}has-text-grey{% endif %}">
|
||||||
{# DESCRIPTION #}
|
{% if notification.notification_type == 'MENTION' %}
|
||||||
{% if notification.related_user %}
|
<span class="icon icon-comment"></span>
|
||||||
{% include 'snippets/avatar.html' with user=notification.related_user %}
|
|
||||||
{% include 'snippets/username.html' with user=notification.related_user %}
|
|
||||||
{% if notification.notification_type == 'FAVORITE' %}
|
|
||||||
favorited your
|
|
||||||
<a href="{{ notification.related_status.local_path }}">status</a>
|
|
||||||
|
|
||||||
{% elif notification.notification_type == 'MENTION' %}
|
|
||||||
mentioned you in a
|
|
||||||
<a href="{{ notification.related_status.local_path }}">status</a>
|
|
||||||
|
|
||||||
{% elif notification.notification_type == 'REPLY' %}
|
{% elif notification.notification_type == 'REPLY' %}
|
||||||
<a href="{{ notification.related_status.local_path }}">replied</a>
|
<span class="icon icon-comments"></span>
|
||||||
to your
|
{% elif notification.notification_type == 'FOLLOW' or notification.notification_type == 'FOLLOW_REQUEST' %}
|
||||||
<a href="{{ notification.related_status.reply_parent.local_path }}">status</a>
|
<span class="icon icon-local"></span>
|
||||||
{% elif notification.notification_type == 'FOLLOW' %}
|
|
||||||
followed you
|
|
||||||
{% elif notification.notification_type == 'FOLLOW_REQUEST' %}
|
|
||||||
sent you a follow request
|
|
||||||
<div class="row shrink">
|
|
||||||
{% include 'snippets/follow_request_buttons.html' with user=notification.related_user %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% elif notification.notification_type == 'BOOST' %}
|
{% elif notification.notification_type == 'BOOST' %}
|
||||||
boosted your <a href="{{ notification.related_status.local_path }}">status</a>
|
<span class="icon icon-boost"></span>
|
||||||
|
{% elif notification.notification_type == 'FAVORITE' %}
|
||||||
|
<span class="icon icon-heart"></span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
</div>
|
||||||
your <a href="/import-status/{{ notification.related_import.id }}">import</a> completed.
|
<div class="column">
|
||||||
{% endif %}
|
<div class="block">
|
||||||
</p>
|
<p>
|
||||||
</div>
|
{# DESCRIPTION #}
|
||||||
{% if notification.related_status %}
|
{% if notification.related_user %}
|
||||||
<div class="block">
|
{% include 'snippets/avatar.html' with user=notification.related_user %}
|
||||||
{# PREVIEW #}
|
{% include 'snippets/username.html' with user=notification.related_user %}
|
||||||
<div class="notification py-2 {% if notification.id in unread %}is-primary is-light{% else %}has-background-white{% if notification.notification_type == 'REPLY' or notification.notification_type == 'MENTION' %} has-text-black{% else %}-bis has-text-grey-dark{% endif %}{% endif %}">
|
{% if notification.notification_type == 'FAVORITE' %}
|
||||||
<div class="columns">
|
favorited your
|
||||||
<div class="column">
|
<a href="{{ related_status.local_path }}">{{ related_status | status_preview_name|safe }}</a>
|
||||||
<a href="{{ notification.related_status.local_path }}">{{ notification.related_status.content | safe | truncatewords_html:10 }}</a>
|
|
||||||
</div>
|
{% elif notification.notification_type == 'MENTION' %}
|
||||||
<div class="column is-narrow {% if notification.notification_type == 'REPLY' or notification.notification_type == 'MENTION' %}has-text-black{% else %}has-text-grey-dark{% endif %}">
|
mentioned you in a
|
||||||
{{ notification.related_status.published_date | post_date }}
|
<a href="{{ related_status.local_path }}">{{ related_status | status_preview_name|safe }}</a>
|
||||||
{% include 'snippets/privacy-icons.html' with item=notification.related_status %}
|
|
||||||
|
{% elif notification.notification_type == 'REPLY' %}
|
||||||
|
<a href="{{ related_status.local_path }}">replied</a>
|
||||||
|
to your
|
||||||
|
<a href="{{ related_status.reply_parent.local_path }}">{{ related_status | status_preview_name|safe }}</a>
|
||||||
|
{% elif notification.notification_type == 'FOLLOW' %}
|
||||||
|
followed you
|
||||||
|
{% elif notification.notification_type == 'FOLLOW_REQUEST' %}
|
||||||
|
sent you a follow request
|
||||||
|
<div class="row shrink">
|
||||||
|
{% include 'snippets/follow_request_buttons.html' with user=notification.related_user %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% elif notification.notification_type == 'BOOST' %}
|
||||||
|
boosted your <a href="{{ related_status.local_path }}">{{ related_status | status_preview_name|safe }}</a>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
your <a href="/import-status/{{ notification.related_import.id }}">import</a> completed.
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{% if related_status %}
|
||||||
|
<div class="block">
|
||||||
|
{# PREVIEW #}
|
||||||
|
<div class="notification py-2 {% if notification.id in unread %}is-primary is-light{% else %}has-background-white{% if notification.notification_type == 'REPLY' or notification.notification_type == 'MENTION' %} has-text-black{% else %}-bis has-text-grey-dark{% endif %}{% endif %}">
|
||||||
|
<div class="columns">
|
||||||
|
<div class="column">
|
||||||
|
{% if related_status.content %}
|
||||||
|
<a href="{{ related_status.local_path }}">{{ related_status.content | safe | truncatewords_html:10 }}</a>
|
||||||
|
{% elif related_status.quote %}
|
||||||
|
<a href="{{ related_status.local_path }}">{{ related_status.quote | safe | truncatewords_html:10 }}</a>
|
||||||
|
{% elif related_status.rating %}
|
||||||
|
{% include 'snippets/stars.html' with rating=related_status.rating %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="column is-narrow {% if notification.notification_type == 'REPLY' or notification.notification_type == 'MENTION' %}has-text-black{% else %}has-text-grey-dark{% endif %}">
|
||||||
|
{{ related_status.published_date | post_date }}
|
||||||
|
{% include 'snippets/privacy-icons.html' with item=related_status %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,30 @@ def get_mentions(status, user):
|
||||||
return ' '.join(
|
return ' '.join(
|
||||||
'@' + get_user_identifier(m) for m in mentions if not m == user)
|
'@' + get_user_identifier(m) for m in mentions if not m == user)
|
||||||
|
|
||||||
|
@register.filter(name='status_preview_name')
|
||||||
|
def get_status_preview_name(obj):
|
||||||
|
name = obj.__class__.__name__.lower()
|
||||||
|
if name == 'review':
|
||||||
|
return '%s of <em>%s</em>' % (name, obj.book.title)
|
||||||
|
if name == 'comment':
|
||||||
|
return '%s on <em>%s</em>' % (name, obj.book.title)
|
||||||
|
if name == 'quotation':
|
||||||
|
return '%s from <em>%s</em>' % (name, obj.book.title)
|
||||||
|
return name
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
@register.simple_tag(takes_context=True)
|
@register.simple_tag(takes_context=True)
|
||||||
def active_shelf(context, book):
|
def active_shelf(context, book):
|
||||||
''' check what shelf a user has a book on, if any '''
|
''' check what shelf a user has a book on, if any '''
|
||||||
|
|
Loading…
Reference in a new issue