From cf13ad379059dfaa66d109527adec166bbb60430 Mon Sep 17 00:00:00 2001 From: Jason McBrayer Date: Tue, 5 Nov 2019 19:23:58 -0500 Subject: [PATCH] Squashed commit of the following: commit 0a80206abb8fae7785a59aab88043b2b1974756b Author: Jason McBrayer Date: Tue Nov 5 19:22:00 2019 -0500 Fix oxford comma in bundled notifications, remove unused dependency commit e96bd22bdce996734aaaf1d5625e08add3c8fcf7 Author: Jason McBrayer Date: Tue Nov 5 19:19:42 2019 -0500 Now template works with bundled or un-bundled notifications commit 6f46bef7fdd0defe2f02e09e28558de882ce4456 Author: Jason McBrayer Date: Tue Nov 5 19:02:51 2019 -0500 Bundled toots work; now fix unbundled case commit 07d9de49f943d019d04a5a5203081e57dc0741d8 Author: Jason McBrayer Date: Tue Nov 5 14:09:14 2019 -0500 Notifications are now sorted by groups, but not collapsed commit f62666929f12cf0c7db4c68a1468f7e138318a5c Author: Jason McBrayer Date: Tue Nov 5 13:58:41 2019 -0500 Fix saving of bundle_notifications setting commit 335d5f985c968bb84e4b459dabf77d1d7ecad646 Author: Jason McBrayer Date: Mon Nov 4 18:57:54 2019 -0500 Forgot to include migration for bundle notifications preference commit 0e8232591c4f1bb972e9694433c546c9f66b5419 Author: Jason McBrayer Date: Mon Nov 4 18:57:35 2019 -0500 Bundle notifications setting front-end commit 6e945f1ceb2ff19470e164a946a6a48de4142812 Author: Jason McBrayer Date: Mon Nov 4 18:54:49 2019 -0500 Backend code to group notifications --- Pipfile | 1 - brutaldon/forms.py | 1 + .../0023_preference_bundle_notifications.py | 18 ++ brutaldon/models.py | 6 + brutaldon/templates/comma.html | 5 + brutaldon/templates/main/notifications.html | 160 ++++++++++-------- brutaldon/templates/setup/settings.html | 17 ++ brutaldon/views.py | 35 +++- 8 files changed, 174 insertions(+), 69 deletions(-) create mode 100644 brutaldon/migrations/0023_preference_bundle_notifications.py create mode 100644 brutaldon/templates/comma.html diff --git a/Pipfile b/Pipfile index 8db9cfe..9853f9c 100644 --- a/Pipfile +++ b/Pipfile @@ -27,4 +27,3 @@ inscriptis = "*" lxml = "*" [dev-packages] - diff --git a/brutaldon/forms.py b/brutaldon/forms.py index dfc6bd1..84db4cd 100644 --- a/brutaldon/forms.py +++ b/brutaldon/forms.py @@ -38,6 +38,7 @@ class PreferencesForm(forms.ModelForm): "click_to_load", "lightbox", "filter_notifications", + "bundle_notifications", "poll_frequency", ] diff --git a/brutaldon/migrations/0023_preference_bundle_notifications.py b/brutaldon/migrations/0023_preference_bundle_notifications.py new file mode 100644 index 0000000..303aed5 --- /dev/null +++ b/brutaldon/migrations/0023_preference_bundle_notifications.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.7 on 2019-11-04 23:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('brutaldon', '0022_auto_20190506_0938'), + ] + + operations = [ + migrations.AddField( + model_name='preference', + name='bundle_notifications', + field=models.BooleanField(default=False, help_text='Collapse together boosts or likes of the same toot in the notifications page.'), + ), + ] diff --git a/brutaldon/models.py b/brutaldon/models.py index b63f4fe..4a64cf7 100644 --- a/brutaldon/models.py +++ b/brutaldon/models.py @@ -65,6 +65,12 @@ class Preference(models.Model): default=False, help_text=_("""Exclude boosts and favs from your notifications."""), ) + bundle_notifications = models.BooleanField( + default=False, + help_text=_( + """Collapse together boosts or likes of the same toot in the notifications page.""" + ), + ) class Account(models.Model): diff --git a/brutaldon/templates/comma.html b/brutaldon/templates/comma.html new file mode 100644 index 0000000..c73893f --- /dev/null +++ b/brutaldon/templates/comma.html @@ -0,0 +1,5 @@ +{% if not forloop.first %} + {% if forloop.last %}, and + {% else %}, + {% endif %} +{% endif %} diff --git a/brutaldon/templates/main/notifications.html b/brutaldon/templates/main/notifications.html index d6ab510..14bb9cc 100644 --- a/brutaldon/templates/main/notifications.html +++ b/brutaldon/templates/main/notifications.html @@ -3,7 +3,7 @@ {% load taglinks %} {% block title %} -Brutaldon ({{ own_acct.username }}) - Notifications timelime + Brutaldon ({{ own_acct.username }}) - Notifications timelime {% endblock %} {% comment %} @@ -21,73 +21,99 @@ mastodon.notifications()[0] {% block content %} -

Your notifications timeline

-{% for note in notes %} -{% if note.type == 'mention' %} -

- {{ note.account.display_name }} - ({{ note.account.acct }}) - mentioned you. -

-
-{% include "main/toot_partial.html" with toot=note.status reblog=False %} - -{% elif note.type == 'reblog' %} -

- {{ note.account.display_name }} - ({{ note.account.acct }}) - boosted your toot. - ( - {{ note.created_at |humane_time }} - ) -

-{% include "main/toot_partial.html" with toot=note.status reblog=True reblog_by=note.account.acct reblog_icon=note.account.avatar_static %} - -{% elif note.type == 'favourite' %} -

- {{ note.account.display_name }} - ({{ note.account.acct }}) - favorited your toot. - ( - {{ note.created_at |humane_time }} - ) -

-{% include "main/toot_partial.html" with toot=note.status %} - -{% elif note.type == 'follow' %} - - -{% elif note.type == 'poll' %} -

A poll you created or voted in has ended.

- {% include "main/toot_partial.html" with toot=note.status %} - -{% endif %} -{% endfor %} +

Your notifications timeline

+ {% for group in groups %} + {% if bundle_notifications and group.0.type in bundleable %} + {% if group.0.type == 'favourite' %} +

+ {% for account in group.accounts %} + {% include "comma.html" %}{{ account.display_name }} + ({{ account.acct }}) + {% endfor %} + favorited your toot. +

+ {% include "main/toot_partial.html" with toot=group.0.status %} + + {% elif group.0.type == 'reblog' %} +

+ {% for account in group.accounts %} + {% include "comma.html" %}{{ account.display_name }} + ({{ account.acct }}) + {% endfor %} + boosted your toot. +

+ {% include "main/toot_partial.html" with toot=group.0.status reblog=True reblog_by=group.0.account.acct reblog_icon=group.0.account.avatar_static %} + + {% endif %} + {% else %} + {% for note in group %} + {% if note.type == 'mention' %} +

+ {{ note.account.display_name }} + ({{ note.account.acct }}) + mentioned you. +

+
+ {% include "main/toot_partial.html" with toot=note.status reblog=False %} + + {% elif note.type == 'reblog' %} +

+ {{ note.account.display_name }} + ({{ note.account.acct }}) + boosted your toot. + ( + {{ note.created_at |humane_time }} + ) +

+ {% include "main/toot_partial.html" with toot=note.status reblog=True reblog_by=note.account.acct reblog_icon=note.account.avatar_static %} + + {% elif note.type == 'favourite' %} +

+ {{ note.account.display_name }} + ({{ note.account.acct }}) + favorited your toot. + ( + {{ note.created_at |humane_time }} + ) +

+ {% include "main/toot_partial.html" with toot=note.status %} + + {% elif note.type == 'follow' %} + + + {% elif note.type == 'poll' %} +

A poll you created or voted in has ended.

+ {% include "main/toot_partial.html" with toot=note.status %} + + {% endif %} + {% endfor %} + {% endif %} + {% endfor %} - + {% endblock %} diff --git a/brutaldon/templates/setup/settings.html b/brutaldon/templates/setup/settings.html index a8f9e22..2e09f20 100644 --- a/brutaldon/templates/setup/settings.html +++ b/brutaldon/templates/setup/settings.html @@ -125,6 +125,23 @@ +
+
+ +
+
+

+ {{ form.bundle_notifications.help_text }} +

+
+
+ +
+
+