diff --git a/bookwyrm/templates/notifications/item.html b/bookwyrm/templates/notifications/item.html new file mode 100644 index 00000000..29aaf709 --- /dev/null +++ b/bookwyrm/templates/notifications/item.html @@ -0,0 +1,2 @@ +{# load the right template #} +{% include 'notifications/mention.html' %} diff --git a/bookwyrm/templates/notifications/item_layout.html b/bookwyrm/templates/notifications/item_layout.html new file mode 100644 index 00000000..19b6d13d --- /dev/null +++ b/bookwyrm/templates/notifications/item_layout.html @@ -0,0 +1,29 @@ +{% load humanize %} +{% load bookwyrm_tags %} +{% related_status notification as related_status %} +
+
+
+ {% block icon %}{% endblock %} +
+
+
+

+ {% if notification.related_user %} + + {% include 'snippets/avatar.html' with user=notification.related_user %} + {{ notification.related_user.display_name }} + + {% endif %} + {% block description %}{% endblock %} +

+
+ {% if related_status %} +
+ {% block preview %}{% endblock %} +
+ {% endif %} +
+
+
+ diff --git a/bookwyrm/templates/notifications/mention.html b/bookwyrm/templates/notifications/mention.html new file mode 100644 index 00000000..58872ef8 --- /dev/null +++ b/bookwyrm/templates/notifications/mention.html @@ -0,0 +1,60 @@ +{% extends 'notifications/item_layout.html' %} + +{% load i18n %} +{% load utilities %} + + +{% block icon %} + +{% endblock %} + + +{% block description %} + {% with related_status.book|book_title as book_title %} + {% with related_status.local_path as related_path %} + + {% if related_status.status_type == 'Review' %} + {% blocktrans trimmed %} + + mentioned you in a review of {{ book_title }} + + {% endblocktrans %} + {% elif related_status.status_type == 'Comment' %} + {% blocktrans trimmed %} + + mentioned you in a comment on {{ book_title }} + + {% endblocktrans %} + {% elif related_status.status_type == 'Quotation' %} + {% blocktrans trimmed %} + + mentioned you in a quote from {{ book_title }} + + {% endblocktrans %} + {% else %} + {% blocktrans trimmed %} + + mentioned you in a status + + {% endblocktrans %} + {% endif %} + + {% endwith %} + {% endwith %} +{% endblock %} + + + +{% block preview %} +
+
+
+ {% include 'snippets/status_preview.html' with status=related_status %} +
+
+ {{ related_status.published_date|timesince }} + {% include 'snippets/privacy-icons.html' with item=related_status %} +
+
+
+{% endblock %} diff --git a/bookwyrm/templates/notifications/notification_item.html b/bookwyrm/templates/notifications/notification_item.html deleted file mode 100644 index 89754688..00000000 --- a/bookwyrm/templates/notifications/notification_item.html +++ /dev/null @@ -1,118 +0,0 @@ - {% related_status notification as related_status %} -
-
-
- {% if notification.notification_type == 'MENTION' %} - - {% elif notification.notification_type == 'REPLY' %} - - {% elif notification.notification_type == 'FOLLOW' or notification.notification_type == 'FOLLOW_REQUEST' %} - - {% elif notification.notification_type == 'BOOST' %} - - {% elif notification.notification_type == 'FAVORITE' %} - - {% elif notification.notification_type == 'IMPORT' %} - - {% elif notification.notification_type == 'ADD' %} - - {% elif notification.notification_type == 'REPORT' %} - - {% endif %} -
-
-
-

- {# DESCRIPTION #} - {% if notification.related_user %} - - {% include 'snippets/avatar.html' with user=notification.related_user %} - {{ notification.related_user.display_name }} - - {% if notification.notification_type == 'FAVORITE' %} - {% if related_status.status_type == 'Review' %} - {% blocktrans with book_title=related_status.book.title related_path=related_status.local_path %}favorited your review of {{ book_title }}{% endblocktrans %} - {% elif related_status.status_type == 'Comment' %} - {% blocktrans with book_title=related_status.book.title related_path=related_status.local_path %}favorited your comment on {{ book_title }}{% endblocktrans %} - {% elif related_status.status_type == 'Quotation' %} - {% blocktrans with book_title=related_status.book.title related_path=related_status.local_path %}favorited your quote from {{ book_title }}{% endblocktrans %} - {% else %} - {% blocktrans with related_path=related_status.local_path %}favorited your status{% endblocktrans %} - {% endif %} - - {% elif notification.notification_type == 'MENTION' %} - {% if related_status.status_type == 'Review' %} - {% blocktrans with related_path=related_status.local_path book_title=related_status.book.title %}mentioned you in a review of {{ book_title }}{% endblocktrans %} - {% elif related_status.status_type == 'Comment' %} - {% blocktrans with related_path=related_status.local_path book_title=related_status.book.title %}mentioned you in a comment on {{ book_title }}{% endblocktrans %} - {% elif related_status.status_type == 'Quotation' %} - {% blocktrans with related_path=related_status.local_path book_title=related_status.book.title %}mentioned you in a quote from {{ book_title }}{% endblocktrans %} - {% else %} - {% blocktrans with related_path=related_status.local_path %}mentioned you in a status{% endblocktrans %} - {% endif %} - - {% elif notification.notification_type == 'REPLY' %} - {% if related_status.status_type == 'Review' %} - {% blocktrans with related_path=related_status.local_path parent_path=related_status.reply_parent.local_path book_title=related_status.reply_parent.book.title %}replied to your review of {{ book_title }}{% endblocktrans %} - {% elif related_status.status_type == 'Comment' %} - {% blocktrans with related_path=related_status.local_path parent_path=related_status.reply_parent.local_path book_title=related_status.reply_parent.book.title %}replied to your comment on {{ book_title }}{% endblocktrans %} - {% elif related_status.status_type == 'Quotation' %} - {% blocktrans with related_path=related_status.local_path parent_path=related_status.reply_parent.local_path book_title=related_status.reply_parent.book.title %}replied to your quote from {{ book_title }}{% endblocktrans %} - {% else %} - {% blocktrans with related_path=related_status.local_path parent_path=related_status.reply_parent.local_path %}replied to your status{% endblocktrans %} - {% endif %} - - {% elif notification.notification_type == 'FOLLOW' %} - {% trans "followed you" %} - {% include 'snippets/follow_button.html' with user=notification.related_user %} - {% elif notification.notification_type == 'FOLLOW_REQUEST' %} - {% trans "sent you a follow request" %} -

- {% include 'snippets/follow_request_buttons.html' with user=notification.related_user %} -
- {% elif notification.notification_type == 'BOOST' %} - {% if related_status.status_type == 'Review' %} - {% blocktrans with related_path=related_status.local_path book_title=related_status.book.title %}boosted your review of {{ book_title }}{% endblocktrans %} - {% elif related_status.status_type == 'Comment' %} - {% blocktrans with related_path=related_status.local_path book_title=related_status.book.title %}boosted your comment on{{ book_title }}{% endblocktrans %} - {% elif related_status.status_type == 'Quotation' %} - {% blocktrans with related_path=related_status.local_path book_title=related_status.book.title %}boosted your quote from {{ book_title }}{% endblocktrans %} - {% else %} - {% blocktrans with related_path=related_status.local_path %}boosted your status{% endblocktrans %} - {% endif %} - {% elif notification.notification_type == 'ADD' %} - {% if notification.related_list_item.approved %} - {% blocktrans with book_path=notification.related_list_item.book.local_path book_title=notification.related_list_item.book.title list_path=notification.related_list_item.book_list.local_path list_name=notification.related_list_item.book_list.name %} added {{ book_title }} to your list "{{ list_name }}"{% endblocktrans %} - {% else %} - {% blocktrans with book_path=notification.related_list_item.book.local_path book_title=notification.related_list_item.book.title list_path=notification.related_list_item.book_list.local_path list_name=notification.related_list_item.book_list.name %} suggested adding {{ book_title }} to your list "{{ list_name }}"{% endblocktrans %} - {% endif %} - {% endif %} - {% elif notification.related_import %} - {% url 'import-status' notification.related_import.id as url %} - {% blocktrans %}Your import completed.{% endblocktrans %} - {% elif notification.related_report %} - {% url 'settings-report' notification.related_report.id as path %} - {% blocktrans with related_id=path %}A new report needs moderation.{% endblocktrans %} - {% endif %} -

-
- {% if related_status %} -
- {# PREVIEW #} -
-
-
- {% include 'snippets/status_preview.html' with status=related_status %} -
-
- {{ related_status.published_date|timesince }} - {% include 'snippets/privacy-icons.html' with item=related_status %} -
-
-
-
- {% endif %} -
-
-
- diff --git a/bookwyrm/templates/notifications/notifications.html b/bookwyrm/templates/notifications/notifications_page.html similarity index 92% rename from bookwyrm/templates/notifications/notifications.html rename to bookwyrm/templates/notifications/notifications_page.html index 7f882001..79834bd8 100644 --- a/bookwyrm/templates/notifications/notifications.html +++ b/bookwyrm/templates/notifications/notifications_page.html @@ -1,7 +1,5 @@ {% extends 'layout.html' %} {% load i18n %} -{% load bookwyrm_tags %} -{% load humanize %} {% block title %}{% trans "Notifications" %}{% endblock %} @@ -34,7 +32,7 @@
{% for notification in notifications %} - {% include 'notifications/notification_item.html' %} + {% include 'notifications/item.html' %} {% endfor %} {% if not notifications %} diff --git a/bookwyrm/views/notifications.py b/bookwyrm/views/notifications.py index 38b35606..0c82f541 100644 --- a/bookwyrm/views/notifications.py +++ b/bookwyrm/views/notifications.py @@ -24,7 +24,7 @@ class Notifications(View): "unread": unread, } notifications.update(read=True) - return TemplateResponse(request, "notifications/notifications.html", data) + return TemplateResponse(request, "notifications/notifications_page.html", data) def post(self, request): """permanently delete notification for user"""