From 9d765751e86380ead600a3be7475afd53cb5d709 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 2 Oct 2021 07:32:00 -0700 Subject: [PATCH 01/11] Creates notification template directory --- bookwyrm/templates/{ => notifications}/notifications.html | 0 bookwyrm/views/notifications.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename bookwyrm/templates/{ => notifications}/notifications.html (100%) diff --git a/bookwyrm/templates/notifications.html b/bookwyrm/templates/notifications/notifications.html similarity index 100% rename from bookwyrm/templates/notifications.html rename to bookwyrm/templates/notifications/notifications.html diff --git a/bookwyrm/views/notifications.py b/bookwyrm/views/notifications.py index d6897f39..38b35606 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.html", data) + return TemplateResponse(request, "notifications/notifications.html", data) def post(self, request): """permanently delete notification for user""" From 29157d03fc6c846d3f740396d7d92bcf0be586a2 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 2 Oct 2021 07:33:42 -0700 Subject: [PATCH 02/11] Create snippet for notification items --- .../notifications/notification_item.html | 118 ++++++++++++++++++ .../notifications/notifications.html | 118 +----------------- 2 files changed, 119 insertions(+), 117 deletions(-) create mode 100644 bookwyrm/templates/notifications/notification_item.html diff --git a/bookwyrm/templates/notifications/notification_item.html b/bookwyrm/templates/notifications/notification_item.html new file mode 100644 index 00000000..89754688 --- /dev/null +++ b/bookwyrm/templates/notifications/notification_item.html @@ -0,0 +1,118 @@ + {% 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.html index ae5cd67b..7f882001 100644 --- a/bookwyrm/templates/notifications/notifications.html +++ b/bookwyrm/templates/notifications/notifications.html @@ -34,123 +34,7 @@
{% for notification in notifications %} - {% 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 %} -
-
-
+ {% include 'notifications/notification_item.html' %} {% endfor %} {% if not notifications %} From df8f67895cf4409ec8c8636a5ab5b2586a328d5f Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 2 Oct 2021 07:58:20 -0700 Subject: [PATCH 03/11] Adds mention notification template --- bookwyrm/templates/notifications/item.html | 2 + .../templates/notifications/item_layout.html | 29 +++++ bookwyrm/templates/notifications/mention.html | 60 +++++++++ .../notifications/notification_item.html | 118 ------------------ ...fications.html => notifications_page.html} | 4 +- bookwyrm/views/notifications.py | 2 +- 6 files changed, 93 insertions(+), 122 deletions(-) create mode 100644 bookwyrm/templates/notifications/item.html create mode 100644 bookwyrm/templates/notifications/item_layout.html create mode 100644 bookwyrm/templates/notifications/mention.html delete mode 100644 bookwyrm/templates/notifications/notification_item.html rename bookwyrm/templates/notifications/{notifications.html => notifications_page.html} (92%) 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""" From 8f56ad9e996ac546ecfd4bc86b29481829eee177 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 2 Oct 2021 09:50:48 -0700 Subject: [PATCH 04/11] Adds report templates --- bookwyrm/templates/notifications/add.html | 35 +++++++++++ bookwyrm/templates/notifications/boost.html | 57 +++++++++++++++++ bookwyrm/templates/notifications/fav.html | 57 +++++++++++++++++ bookwyrm/templates/notifications/follow.html | 13 ++++ .../notifications/follow_request.html | 15 +++++ bookwyrm/templates/notifications/import.html | 12 ++++ bookwyrm/templates/notifications/item.html | 20 +++++- bookwyrm/templates/notifications/mention.html | 3 +- bookwyrm/templates/notifications/reply.html | 62 +++++++++++++++++++ bookwyrm/templates/notifications/report.html | 12 ++++ 10 files changed, 283 insertions(+), 3 deletions(-) create mode 100644 bookwyrm/templates/notifications/add.html create mode 100644 bookwyrm/templates/notifications/boost.html create mode 100644 bookwyrm/templates/notifications/fav.html create mode 100644 bookwyrm/templates/notifications/follow.html create mode 100644 bookwyrm/templates/notifications/follow_request.html create mode 100644 bookwyrm/templates/notifications/import.html create mode 100644 bookwyrm/templates/notifications/reply.html create mode 100644 bookwyrm/templates/notifications/report.html diff --git a/bookwyrm/templates/notifications/add.html b/bookwyrm/templates/notifications/add.html new file mode 100644 index 00000000..6ccabf41 --- /dev/null +++ b/bookwyrm/templates/notifications/add.html @@ -0,0 +1,35 @@ +{% extends 'notifications/item_layout.html' %} + +{% load i18n %} +{% load utilities %} + +{% block icon %} + +{% endblock %} + +{% block description %} +{% with book_path=notification.related_list_item.book.local_path %} +{% with book_title=notification.related_list_item.book|book_title %} +{% with list_path=notification.related_list_item.book_list.local_path %} +{% with list_name=notification.related_list_item.book_list.name %} + + {% if notification.related_list_item.approved %} + {% blocktrans trimmed %} + + added {{ book_title }} to your list "{{ list_name }}" + + {% endblocktrans %} + {% else %} + {% blocktrans trimmed %} + + suggested adding {{ book_title }} to your list "{{ list_name }}" + + {% endblocktrans %} + {% endif %} + +{% endwith %} +{% endwith %} +{% endwith %} +{% endwith %} +{% endblock %} + diff --git a/bookwyrm/templates/notifications/boost.html b/bookwyrm/templates/notifications/boost.html new file mode 100644 index 00000000..0653e8ee --- /dev/null +++ b/bookwyrm/templates/notifications/boost.html @@ -0,0 +1,57 @@ +{% 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 %} + + boosted your review of {{ book_title }} + + {% endblocktrans %} + {% elif related_status.status_type == 'Comment' %} + {% blocktrans trimmed %} + + boosted your comment on{{ book_title }} + + {% endblocktrans %} + {% elif related_status.status_type == 'Quotation' %} + {% blocktrans trimmed %} + + boosted your quote from {{ book_title }} + + {% endblocktrans %} + {% else %} + {% blocktrans trimmed %} + + boosted your 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/fav.html b/bookwyrm/templates/notifications/fav.html new file mode 100644 index 00000000..c9507067 --- /dev/null +++ b/bookwyrm/templates/notifications/fav.html @@ -0,0 +1,57 @@ +{% 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 %} + + favorited your review of {{ book_title }} + + {% endblocktrans %} + {% elif related_status.status_type == 'Comment' %} + {% blocktrans trimmed %} + + favorited your comment on{{ book_title }} + + {% endblocktrans %} + {% elif related_status.status_type == 'Quotation' %} + {% blocktrans trimmed %} + + favorited your quote from {{ book_title }} + + {% endblocktrans %} + {% else %} + {% blocktrans trimmed %} + + favorited your 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/follow.html b/bookwyrm/templates/notifications/follow.html new file mode 100644 index 00000000..8ae0caa7 --- /dev/null +++ b/bookwyrm/templates/notifications/follow.html @@ -0,0 +1,13 @@ +{% extends 'notifications/item_layout.html' %} + +{% load i18n %} +{% load utilities %} + +{% block icon %} + +{% endblock %} + +{% block description %} + {% trans "followed you" %} + {% include 'snippets/follow_button.html' with user=notification.related_user %} +{% endblock %} diff --git a/bookwyrm/templates/notifications/follow_request.html b/bookwyrm/templates/notifications/follow_request.html new file mode 100644 index 00000000..33c0bd1f --- /dev/null +++ b/bookwyrm/templates/notifications/follow_request.html @@ -0,0 +1,15 @@ +{% extends 'notifications/item_layout.html' %} + +{% load i18n %} +{% load utilities %} + +{% block icon %} + +{% endblock %} + +{% block description %} + {% trans "sent you a follow request" %} +
+ {% include 'snippets/follow_request_buttons.html' with user=notification.related_user %} +
+{% endblock %} diff --git a/bookwyrm/templates/notifications/import.html b/bookwyrm/templates/notifications/import.html new file mode 100644 index 00000000..1d311195 --- /dev/null +++ b/bookwyrm/templates/notifications/import.html @@ -0,0 +1,12 @@ +{% extends 'notifications/item_layout.html' %} + +{% load i18n %} + +{% block icon %} + +{% endblock %} + +{% block description %} + {% url 'import-status' notification.related_import.id as url %} + {% blocktrans %}Your import completed.{% endblocktrans %} +{% endblock %} diff --git a/bookwyrm/templates/notifications/item.html b/bookwyrm/templates/notifications/item.html index 29aaf709..6c2ab7fe 100644 --- a/bookwyrm/templates/notifications/item.html +++ b/bookwyrm/templates/notifications/item.html @@ -1,2 +1,20 @@ {# load the right template #} -{% include 'notifications/mention.html' %} +{% if notification.notification_type == 'MENTION' %} + {% include 'notifications/mention.html' %} +{% elif notification.notification_type == 'REPLY' %} + {% include 'notifications/reply.html' %} +{% elif notification.notification_type == 'BOOST' %} + {% include 'notifications/boost.html' %} +{% elif notification.notification_type == 'FAVORITE' %} + {% include 'notifications/fav.html' %} +{% elif notification.notification_type == 'FOLLOW' %} + {% include 'notifications/follow.html' %} +{% elif notification.notification_type == 'FOLLOW_REQUEST' %} + {% include 'notifications/follow_request.html' %} +{% elif notification.notification_type == 'IMPORT' %} + {% include 'notifications/import.html' %} +{% elif notification.notification_type == 'ADD' %} + {% include 'notifications/add.html' %} +{% elif notification.notification_type == 'REPORT' %} + {% include 'notifications/report.html' %} +{% endif %} diff --git a/bookwyrm/templates/notifications/mention.html b/bookwyrm/templates/notifications/mention.html index 58872ef8..c456afdb 100644 --- a/bookwyrm/templates/notifications/mention.html +++ b/bookwyrm/templates/notifications/mention.html @@ -44,14 +44,13 @@ {% 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 %}
diff --git a/bookwyrm/templates/notifications/reply.html b/bookwyrm/templates/notifications/reply.html new file mode 100644 index 00000000..d34a267b --- /dev/null +++ b/bookwyrm/templates/notifications/reply.html @@ -0,0 +1,62 @@ +{% extends 'notifications/item_layout.html' %} + +{% load i18n %} +{% load utilities %} + + +{% block icon %} + +{% endblock %} + + +{% block description %} + {% with related_status.reply_parent.book|book_title as book_title %} + {% with related_status.local_path as related_path %} + {% with related_status.reply_parent.local_path as parent_path %} + + {% if related_status.reply_parent.status_type == 'Review' %} + {% blocktrans trimmed %} + + replied to your review of {{ book_title }} + + {% endblocktrans %} + {% elif related_status.reply_parent.status_type == 'Comment' %} + {% blocktrans trimmed %} + + replied to your comment on {{ book_title }} + + {% endblocktrans %} + {% elif related_status.reply_parent.status_type == 'Quotation' %} + {% blocktrans trimmed %} + + replied to your quote from {{ book_title }} + + {% endblocktrans %} + {% else %} + {% blocktrans trimmed %} + + replied to your status + + {% endblocktrans %} + {% endif %} + + {% endwith %} + {% 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/report.html b/bookwyrm/templates/notifications/report.html new file mode 100644 index 00000000..ca0c877d --- /dev/null +++ b/bookwyrm/templates/notifications/report.html @@ -0,0 +1,12 @@ +{% extends 'notifications/item_layout.html' %} + +{% load i18n %} + +{% block icon %} + +{% endblock %} + +{% block description %} + {% url 'settings-report' notification.related_report.id as path %} + {% blocktrans %}A new report needs moderation.{% endblocktrans %} +{% endblock %} From 085d3270a328102d20d21ffe755c96b0042b05f1 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 2 Oct 2021 10:10:25 -0700 Subject: [PATCH 05/11] Load related objects in query Reduces query load in template --- bookwyrm/views/notifications.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bookwyrm/views/notifications.py b/bookwyrm/views/notifications.py index 0c82f541..0a7a6200 100644 --- a/bookwyrm/views/notifications.py +++ b/bookwyrm/views/notifications.py @@ -13,7 +13,20 @@ class Notifications(View): def get(self, request, notification_type=None): """people are interacting with you, get hyped""" - notifications = request.user.notification_set.all().order_by("-created_date") + notifications = ( + request.user.notification_set.all() + .order_by("-created_date") + .select_related( + "related_status", + "related_status__reply_parent", + "related_import", + "related_report", + "related_user", + "related_book", + "related_list_item", + "related_list_item__book", + ) + ) if notification_type == "mentions": notifications = notifications.filter( notification_type__in=["REPLY", "MENTION", "TAG"] From 1d79bb58e198f9f6c610bb611fc1b33197f13187 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 2 Oct 2021 10:28:49 -0700 Subject: [PATCH 06/11] Better mobile display for notifications --- bookwyrm/templates/notifications/notifications_page.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/notifications/notifications_page.html b/bookwyrm/templates/notifications/notifications_page.html index 79834bd8..8d1cf6ad 100644 --- a/bookwyrm/templates/notifications/notifications_page.html +++ b/bookwyrm/templates/notifications/notifications_page.html @@ -4,14 +4,19 @@ {% block title %}{% trans "Notifications" %}{% endblock %} {% block content %} -
+

{% trans "Notifications" %}

{% csrf_token %} - + {% spaceless %} + + {% endspaceless %}
From 0320898f4e528cd7481278b7964e4613741f770a Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 2 Oct 2021 10:37:59 -0700 Subject: [PATCH 07/11] Expands notifications views test --- bookwyrm/tests/views/test_notifications.py | 42 ++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/bookwyrm/tests/views/test_notifications.py b/bookwyrm/tests/views/test_notifications.py index d97616ce..dd28a811 100644 --- a/bookwyrm/tests/views/test_notifications.py +++ b/bookwyrm/tests/views/test_notifications.py @@ -6,6 +6,7 @@ from django.test.client import RequestFactory from bookwyrm import models from bookwyrm import views +from bookwyrm.tests.validate_html import validate_html class NotificationViews(TestCase): @@ -24,16 +25,53 @@ class NotificationViews(TestCase): local=True, localname="mouse", ) + with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"): + self.status = models.Status.objects.create( + content="hi", + user=self.local_user, + ) models.SiteSettings.objects.create() - def test_notifications_page(self): + def test_notifications_page_empty(self): """there are so many views, this just makes sure it LOADS""" view = views.Notifications.as_view() request = self.factory.get("") request.user = self.local_user result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) + self.assertEqual(result.status_code, 200) + + def test_notifications_page_notifications(self): + """there are so many views, this just makes sure it LOADS""" + models.Notification.objects.create( + user=self.local_user, + notification_type="FAVORITE", + related_status=self.status, + ) + models.Notification.objects.create( + user=self.local_user, + notification_type="BOOST", + related_status=self.status, + ) + models.Notification.objects.create( + user=self.local_user, + notification_type="MENTION", + related_status=self.status, + ) + self.status.reply_parent = self.status + self.status.save(broadcast=False) + models.Notification.objects.create( + user=self.local_user, + notification_type="REPLY", + related_status=self.status, + ) + view = views.Notifications.as_view() + request = self.factory.get("") + request.user = self.local_user + result = view(request) + self.assertIsInstance(result, TemplateResponse) + validate_html(result.render()) self.assertEqual(result.status_code, 200) def test_clear_notifications(self): From 5adbf2d08756b3648b143866289f8960e2019d10 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 2 Oct 2021 10:46:09 -0700 Subject: [PATCH 08/11] Move notification items into dir --- bookwyrm/templates/notifications/item.html | 18 +++++++++--------- .../notifications/{ => items}/add.html | 2 +- .../notifications/{ => items}/boost.html | 2 +- .../notifications/{ => items}/fav.html | 2 +- .../notifications/{ => items}/follow.html | 2 +- .../{ => items}/follow_request.html | 2 +- .../notifications/{ => items}/import.html | 2 +- .../notifications/{ => items}/item_layout.html | 0 .../notifications/{ => items}/mention.html | 2 +- .../notifications/{ => items}/reply.html | 2 +- .../notifications/{ => items}/report.html | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-) rename bookwyrm/templates/notifications/{ => items}/add.html (94%) rename bookwyrm/templates/notifications/{ => items}/boost.html (96%) rename bookwyrm/templates/notifications/{ => items}/fav.html (96%) rename bookwyrm/templates/notifications/{ => items}/follow.html (83%) rename bookwyrm/templates/notifications/{ => items}/follow_request.html (86%) rename bookwyrm/templates/notifications/{ => items}/import.html (84%) rename bookwyrm/templates/notifications/{ => items}/item_layout.html (100%) rename bookwyrm/templates/notifications/{ => items}/mention.html (96%) rename bookwyrm/templates/notifications/{ => items}/reply.html (97%) rename bookwyrm/templates/notifications/{ => items}/report.html (84%) diff --git a/bookwyrm/templates/notifications/item.html b/bookwyrm/templates/notifications/item.html index 6c2ab7fe..348d8950 100644 --- a/bookwyrm/templates/notifications/item.html +++ b/bookwyrm/templates/notifications/item.html @@ -1,20 +1,20 @@ {# load the right template #} {% if notification.notification_type == 'MENTION' %} - {% include 'notifications/mention.html' %} + {% include 'notifications/items/mention.html' %} {% elif notification.notification_type == 'REPLY' %} - {% include 'notifications/reply.html' %} + {% include 'notifications/items/reply.html' %} {% elif notification.notification_type == 'BOOST' %} - {% include 'notifications/boost.html' %} + {% include 'notifications/items/boost.html' %} {% elif notification.notification_type == 'FAVORITE' %} - {% include 'notifications/fav.html' %} + {% include 'notifications/items/fav.html' %} {% elif notification.notification_type == 'FOLLOW' %} - {% include 'notifications/follow.html' %} + {% include 'notifications/items/follow.html' %} {% elif notification.notification_type == 'FOLLOW_REQUEST' %} - {% include 'notifications/follow_request.html' %} + {% include 'notifications/items/follow_request.html' %} {% elif notification.notification_type == 'IMPORT' %} - {% include 'notifications/import.html' %} + {% include 'notifications/items/import.html' %} {% elif notification.notification_type == 'ADD' %} - {% include 'notifications/add.html' %} + {% include 'notifications/items/add.html' %} {% elif notification.notification_type == 'REPORT' %} - {% include 'notifications/report.html' %} + {% include 'notifications/items/report.html' %} {% endif %} diff --git a/bookwyrm/templates/notifications/add.html b/bookwyrm/templates/notifications/items/add.html similarity index 94% rename from bookwyrm/templates/notifications/add.html rename to bookwyrm/templates/notifications/items/add.html index 6ccabf41..50cba16b 100644 --- a/bookwyrm/templates/notifications/add.html +++ b/bookwyrm/templates/notifications/items/add.html @@ -1,4 +1,4 @@ -{% extends 'notifications/item_layout.html' %} +{% extends 'notifications/items/item_layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/boost.html b/bookwyrm/templates/notifications/items/boost.html similarity index 96% rename from bookwyrm/templates/notifications/boost.html rename to bookwyrm/templates/notifications/items/boost.html index 0653e8ee..8ba868f5 100644 --- a/bookwyrm/templates/notifications/boost.html +++ b/bookwyrm/templates/notifications/items/boost.html @@ -1,4 +1,4 @@ -{% extends 'notifications/item_layout.html' %} +{% extends 'notifications/items/item_layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/fav.html b/bookwyrm/templates/notifications/items/fav.html similarity index 96% rename from bookwyrm/templates/notifications/fav.html rename to bookwyrm/templates/notifications/items/fav.html index c9507067..fb61e59e 100644 --- a/bookwyrm/templates/notifications/fav.html +++ b/bookwyrm/templates/notifications/items/fav.html @@ -1,4 +1,4 @@ -{% extends 'notifications/item_layout.html' %} +{% extends 'notifications/items/item_layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/follow.html b/bookwyrm/templates/notifications/items/follow.html similarity index 83% rename from bookwyrm/templates/notifications/follow.html rename to bookwyrm/templates/notifications/items/follow.html index 8ae0caa7..d85d2af3 100644 --- a/bookwyrm/templates/notifications/follow.html +++ b/bookwyrm/templates/notifications/items/follow.html @@ -1,4 +1,4 @@ -{% extends 'notifications/item_layout.html' %} +{% extends 'notifications/items/item_layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/follow_request.html b/bookwyrm/templates/notifications/items/follow_request.html similarity index 86% rename from bookwyrm/templates/notifications/follow_request.html rename to bookwyrm/templates/notifications/items/follow_request.html index 33c0bd1f..febb0a50 100644 --- a/bookwyrm/templates/notifications/follow_request.html +++ b/bookwyrm/templates/notifications/items/follow_request.html @@ -1,4 +1,4 @@ -{% extends 'notifications/item_layout.html' %} +{% extends 'notifications/items/item_layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/import.html b/bookwyrm/templates/notifications/items/import.html similarity index 84% rename from bookwyrm/templates/notifications/import.html rename to bookwyrm/templates/notifications/items/import.html index 1d311195..87dd0998 100644 --- a/bookwyrm/templates/notifications/import.html +++ b/bookwyrm/templates/notifications/items/import.html @@ -1,4 +1,4 @@ -{% extends 'notifications/item_layout.html' %} +{% extends 'notifications/items/item_layout.html' %} {% load i18n %} diff --git a/bookwyrm/templates/notifications/item_layout.html b/bookwyrm/templates/notifications/items/item_layout.html similarity index 100% rename from bookwyrm/templates/notifications/item_layout.html rename to bookwyrm/templates/notifications/items/item_layout.html diff --git a/bookwyrm/templates/notifications/mention.html b/bookwyrm/templates/notifications/items/mention.html similarity index 96% rename from bookwyrm/templates/notifications/mention.html rename to bookwyrm/templates/notifications/items/mention.html index c456afdb..003f4e29 100644 --- a/bookwyrm/templates/notifications/mention.html +++ b/bookwyrm/templates/notifications/items/mention.html @@ -1,4 +1,4 @@ -{% extends 'notifications/item_layout.html' %} +{% extends 'notifications/items/item_layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/reply.html b/bookwyrm/templates/notifications/items/reply.html similarity index 97% rename from bookwyrm/templates/notifications/reply.html rename to bookwyrm/templates/notifications/items/reply.html index d34a267b..125e4dec 100644 --- a/bookwyrm/templates/notifications/reply.html +++ b/bookwyrm/templates/notifications/items/reply.html @@ -1,4 +1,4 @@ -{% extends 'notifications/item_layout.html' %} +{% extends 'notifications/items/item_layout.html' %} {% load i18n %} {% load utilities %} diff --git a/bookwyrm/templates/notifications/report.html b/bookwyrm/templates/notifications/items/report.html similarity index 84% rename from bookwyrm/templates/notifications/report.html rename to bookwyrm/templates/notifications/items/report.html index ca0c877d..9e56d352 100644 --- a/bookwyrm/templates/notifications/report.html +++ b/bookwyrm/templates/notifications/items/report.html @@ -1,4 +1,4 @@ -{% extends 'notifications/item_layout.html' %} +{% extends 'notifications/items/item_layout.html' %} {% load i18n %} From 2a9f8f8122df738acb38f278e91ee109f10a0e51 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 2 Oct 2021 10:52:35 -0700 Subject: [PATCH 09/11] Updates curated list notification link generation --- bookwyrm/templates/notifications/items/add.html | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bookwyrm/templates/notifications/items/add.html b/bookwyrm/templates/notifications/items/add.html index 50cba16b..8e1c46a3 100644 --- a/bookwyrm/templates/notifications/items/add.html +++ b/bookwyrm/templates/notifications/items/add.html @@ -10,19 +10,19 @@ {% block description %} {% with book_path=notification.related_list_item.book.local_path %} {% with book_title=notification.related_list_item.book|book_title %} -{% with list_path=notification.related_list_item.book_list.local_path %} {% with list_name=notification.related_list_item.book_list.name %} {% if notification.related_list_item.approved %} - {% blocktrans trimmed %} + {% blocktrans trimmed with list_path=notification.related_list_item.book_list.local_path %} added {{ book_title }} to your list "{{ list_name }}" {% endblocktrans %} {% else %} - {% blocktrans trimmed %} + {% url 'list-curate' notification.related_list_item.book_list.id as list_path %} + {% blocktrans trimmed with list_path=list_path %} - suggested adding {{ book_title }} to your list "{{ list_name }}" + suggested adding {{ book_title }} to your list "{{ list_name }}" {% endblocktrans %} {% endif %} @@ -30,6 +30,5 @@ {% endwith %} {% endwith %} {% endwith %} -{% endwith %} {% endblock %} From b9632039f9ada9006b4b125c56bdb4adf57222d2 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 2 Oct 2021 11:24:07 -0700 Subject: [PATCH 10/11] Link notification block to its main path --- bookwyrm/static/js/block_href.js | 22 +++++++++++++++++++ .../templates/notifications/items/add.html | 8 +++++++ .../templates/notifications/items/boost.html | 4 ++++ .../templates/notifications/items/fav.html | 4 ++++ .../templates/notifications/items/follow.html | 4 ++++ .../templates/notifications/items/import.html | 5 ++++- .../notifications/items/item_layout.html | 2 +- .../notifications/items/mention.html | 3 +++ .../templates/notifications/items/reply.html | 3 +++ .../templates/notifications/items/report.html | 4 ++++ .../notifications/notifications_page.html | 5 +++++ 11 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 bookwyrm/static/js/block_href.js diff --git a/bookwyrm/static/js/block_href.js b/bookwyrm/static/js/block_href.js new file mode 100644 index 00000000..1de6ca66 --- /dev/null +++ b/bookwyrm/static/js/block_href.js @@ -0,0 +1,22 @@ +/* exported BlockHref */ +/* globals BookWyrm */ + +let BlockHref = new class { + constructor() { + document.querySelectorAll('[data-href]') + .forEach(t => t.addEventListener('click', this.followLink.bind(this))); + } + + /** + * Follow a fake link + * + * @param {Event} event + * @return {undefined} + */ + followLink(event) { + const url = event.currentTarget.dataset.href; + + window.location.href = url; + } +}(); + diff --git a/bookwyrm/templates/notifications/items/add.html b/bookwyrm/templates/notifications/items/add.html index 8e1c46a3..0e653aeb 100644 --- a/bookwyrm/templates/notifications/items/add.html +++ b/bookwyrm/templates/notifications/items/add.html @@ -3,6 +3,14 @@ {% load i18n %} {% load utilities %} +{% block primary_link %}{% spaceless %} +{% if notification.related_list_item.approved %} + {{ notification.related_list_item.book_list.local_path }} +{% else %} + {% url 'list-curate' notification.related_list_item.book_list.id %} +{% endif %} +{% endspaceless %}{% endblock %} + {% block icon %} {% endblock %} diff --git a/bookwyrm/templates/notifications/items/boost.html b/bookwyrm/templates/notifications/items/boost.html index 8ba868f5..5f8962b3 100644 --- a/bookwyrm/templates/notifications/items/boost.html +++ b/bookwyrm/templates/notifications/items/boost.html @@ -3,6 +3,10 @@ {% load i18n %} {% load utilities %} +{% block primary_link %}{% spaceless %} + {{ notification.related_status.local_path }} +{% endspaceless %}{% endblock %} + {% block icon %} {% endblock %} diff --git a/bookwyrm/templates/notifications/items/fav.html b/bookwyrm/templates/notifications/items/fav.html index fb61e59e..d430598e 100644 --- a/bookwyrm/templates/notifications/items/fav.html +++ b/bookwyrm/templates/notifications/items/fav.html @@ -3,6 +3,10 @@ {% load i18n %} {% load utilities %} +{% block primary_link %}{% spaceless %} + {{ notification.related_status.local_path }} +{% endspaceless %}{% endblock %} + {% block icon %} {% endblock %} diff --git a/bookwyrm/templates/notifications/items/follow.html b/bookwyrm/templates/notifications/items/follow.html index d85d2af3..7220d5d1 100644 --- a/bookwyrm/templates/notifications/items/follow.html +++ b/bookwyrm/templates/notifications/items/follow.html @@ -3,6 +3,10 @@ {% load i18n %} {% load utilities %} +{% block primary_link %}{% spaceless %} + {{ notification.related_user.local_path }} +{% endspaceless %}{% endblock %} + {% block icon %} {% endblock %} diff --git a/bookwyrm/templates/notifications/items/import.html b/bookwyrm/templates/notifications/items/import.html index 87dd0998..f3c8b5c0 100644 --- a/bookwyrm/templates/notifications/items/import.html +++ b/bookwyrm/templates/notifications/items/import.html @@ -1,7 +1,10 @@ {% extends 'notifications/items/item_layout.html' %} - {% load i18n %} +{% block primary_link %}{% spaceless %} +{% url 'import-status' notification.related_import.id %} +{% endspaceless %}{% endblock %} + {% block icon %} {% endblock %} diff --git a/bookwyrm/templates/notifications/items/item_layout.html b/bookwyrm/templates/notifications/items/item_layout.html index 19b6d13d..382978d4 100644 --- a/bookwyrm/templates/notifications/items/item_layout.html +++ b/bookwyrm/templates/notifications/items/item_layout.html @@ -1,7 +1,7 @@ {% load humanize %} {% load bookwyrm_tags %} {% related_status notification as related_status %} -
+
{% block icon %}{% endblock %} diff --git a/bookwyrm/templates/notifications/items/mention.html b/bookwyrm/templates/notifications/items/mention.html index 003f4e29..cda77163 100644 --- a/bookwyrm/templates/notifications/items/mention.html +++ b/bookwyrm/templates/notifications/items/mention.html @@ -3,6 +3,9 @@ {% load i18n %} {% load utilities %} +{% block primary_link %}{% spaceless %} + {{ notification.related_status.local_path }} +{% endspaceless %}{% endblock %} {% block icon %} diff --git a/bookwyrm/templates/notifications/items/reply.html b/bookwyrm/templates/notifications/items/reply.html index 125e4dec..883bbbb5 100644 --- a/bookwyrm/templates/notifications/items/reply.html +++ b/bookwyrm/templates/notifications/items/reply.html @@ -3,6 +3,9 @@ {% load i18n %} {% load utilities %} +{% block primary_link %}{% spaceless %} + {{ notification.related_status.local_path }} +{% endspaceless %}{% endblock %} {% block icon %} diff --git a/bookwyrm/templates/notifications/items/report.html b/bookwyrm/templates/notifications/items/report.html index 9e56d352..f537b525 100644 --- a/bookwyrm/templates/notifications/items/report.html +++ b/bookwyrm/templates/notifications/items/report.html @@ -2,6 +2,10 @@ {% load i18n %} +{% block primary_link %}{% spaceless %} + {% url 'settings-report' notification.related_report.id %} +{% endspaceless %}{% endblock %} + {% block icon %} {% endblock %} diff --git a/bookwyrm/templates/notifications/notifications_page.html b/bookwyrm/templates/notifications/notifications_page.html index 8d1cf6ad..dc6acbdb 100644 --- a/bookwyrm/templates/notifications/notifications_page.html +++ b/bookwyrm/templates/notifications/notifications_page.html @@ -1,5 +1,6 @@ {% extends 'layout.html' %} {% load i18n %} +{% load static %} {% block title %}{% trans "Notifications" %}{% endblock %} @@ -45,3 +46,7 @@ {% endif %}
{% endblock %} + +{% block scripts %} + +{% endblock %} From db745383454cc0b5b83323a158f9072f3fca94b9 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 2 Oct 2021 11:28:16 -0700 Subject: [PATCH 11/11] Update for js linter --- bookwyrm/static/js/block_href.js | 1 - 1 file changed, 1 deletion(-) diff --git a/bookwyrm/static/js/block_href.js b/bookwyrm/static/js/block_href.js index 1de6ca66..fc20a6ab 100644 --- a/bookwyrm/static/js/block_href.js +++ b/bookwyrm/static/js/block_href.js @@ -1,5 +1,4 @@ /* exported BlockHref */ -/* globals BookWyrm */ let BlockHref = new class { constructor() {