From ed013ff6bee99a445dbf2223cf9c3c33dea516e1 Mon Sep 17 00:00:00 2001 From: florimondmanca <florimond.manca@gmail.com> Date: Tue, 3 Jul 2018 22:39:01 +0100 Subject: [PATCH] fix projets notifications recipients --- projects/notifications.py | 14 +++++++------- tests/test_projects/test_signals.py | 7 +++++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/projects/notifications.py b/projects/notifications.py index 2ef5f91..5b2fd10 100644 --- a/projects/notifications.py +++ b/projects/notifications.py @@ -29,11 +29,11 @@ class _NotifyOrgnizers(_BaseParticipationNotification): def get_subject(self): return f'{self.title}: {self.edition}' - def get_recipients(self): - """Return the email of each organizer.""" - edition = self.kwargs['edition'] - # TODO add the project team's email - return list(edition.values_list('organizers__email', flat=True)) + def get_recipients(self): + """Return the email of each organizer.""" + edition = self.kwargs['edition'] + # TODO add the project team's email + return list(edition.organizers.values_list('email', flat=True)) class _NotifyUser(_BaseParticipationNotification): @@ -44,8 +44,8 @@ class _NotifyUser(_BaseParticipationNotification): def get_subject(self): return f'Dossier {self.verb}: {self.edition}' - def get_recipients(self): - return [self.kwargs['user'].email] + def get_recipients(self): + return [self.kwargs['user'].email] class OrganizersReceived(_NotifyOrgnizers): diff --git a/tests/test_projects/test_signals.py b/tests/test_projects/test_signals.py index 93e290f..52649c9 100644 --- a/tests/test_projects/test_signals.py +++ b/tests/test_projects/test_signals.py @@ -8,7 +8,7 @@ from dynamicforms.models import Form from profiles.factory import TutorFactory from projects.factory import (EditionFactory, ParticipationFactory, ProjectFactory) -from projects.models import EditionForm, Participation +from projects.models import EditionForm, Participation, EditionOrganizer from projects.signals import (accepted, cancelled, deleted, pending, rejected, valid) @@ -19,8 +19,11 @@ class NotifyParticipationTest(SignalTestMixin, TestCase): def setUp(self): # Create all objects that need to exist for rendering emails project = ProjectFactory.create(name='Focus Europe') - self.edition = EditionFactory.create(project=project, year=2018) recipient = TutorFactory.create() + self.edition = EditionFactory.create(project=project, year=2018) + EditionOrganizer.objects.create( + user=recipient.user, + edition=self.edition) form = Form.objects.create(title=f'Inscriptions à {self.edition}') EditionForm.objects.create( edition=self.edition, -- GitLab