From 58aacdeda4c26f34322682b27083122cfd38c241 Mon Sep 17 00:00:00 2001 From: Ernst Odolphi Date: Mon, 15 Jan 2024 11:42:25 +0100 Subject: [PATCH 1/2] Hide slot title when rendering an email that has a single related slot --- .../mails/messages/partial/slot.html | 4 +++- .../mails/messages/partial/slots.html | 2 +- .../time_based/tests/test_notifications.py | 22 +++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/bluebottle/time_based/templates/mails/messages/partial/slot.html b/bluebottle/time_based/templates/mails/messages/partial/slot.html index 56f4f959ec..dd3771be4e 100644 --- a/bluebottle/time_based/templates/mails/messages/partial/slot.html +++ b/bluebottle/time_based/templates/mails/messages/partial/slot.html @@ -1,6 +1,8 @@ {% load i18n %}

- {{ slot.title }} + {% if slot_count > 1 %} + {{ slot.title }} + {% endif %} {% if slot.changed %} {% trans "Changed" %} {% endif %} diff --git a/bluebottle/time_based/templates/mails/messages/partial/slots.html b/bluebottle/time_based/templates/mails/messages/partial/slots.html index 7baa10fd2a..a6a43eaece 100644 --- a/bluebottle/time_based/templates/mails/messages/partial/slots.html +++ b/bluebottle/time_based/templates/mails/messages/partial/slots.html @@ -1,6 +1,6 @@ {% load i18n %} {% for slot in slots %} - {% include 'mails/messages/partial/slot.html' %} + {% include 'mails/messages/partial/slot.html' with slot_count=slots|length %} {% endfor %}

diff --git a/bluebottle/time_based/tests/test_notifications.py b/bluebottle/time_based/tests/test_notifications.py index 17d60a0870..bfde1b9b4f 100644 --- a/bluebottle/time_based/tests/test_notifications.py +++ b/bluebottle/time_based/tests/test_notifications.py @@ -212,7 +212,29 @@ def test_participant_joined_notification(self): self.assertBodyContains( 'Go to the activity page to see the times in your own timezone and add them to your calendar.' ) + for slot in self.activity.slots.all(): + self.assertBodyContains( + slot.title + ) + def test_participant_joined_single_slot_notification(self): + self.message_class = ParticipantJoinedNotification + for slot in self.slots[:2]: + slot.delete() + + self.slots = [self.slots[0]] + self.create() + self.assertRecipients([self.supporter]) + self.assertSubject('You have joined the activity "Save the world!"') + self.assertActionLink(self.activity.get_absolute_url()) + self.assertActionTitle('View activity') + self.assertBodyContains( + 'Go to the activity page to see the times in your own timezone and add them to your calendar.' + ) + for slot in self.activity.slots.all(): + self.assertBodyNotContains( + slot.title + ) class PeriodParticipantNotificationTestCase(NotificationTestCase): From 6d26992130775c27e97ffa7c2c7708f5970ad2f0 Mon Sep 17 00:00:00 2001 From: Loek van Gent Date: Wed, 31 Jan 2024 09:11:11 +0100 Subject: [PATCH 2/2] PEP8 --- bluebottle/time_based/tests/test_notifications.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bluebottle/time_based/tests/test_notifications.py b/bluebottle/time_based/tests/test_notifications.py index bfde1b9b4f..d746ecb173 100644 --- a/bluebottle/time_based/tests/test_notifications.py +++ b/bluebottle/time_based/tests/test_notifications.py @@ -236,6 +236,7 @@ def test_participant_joined_single_slot_notification(self): slot.title ) + class PeriodParticipantNotificationTestCase(NotificationTestCase): def setUp(self):