[damned-lies] Ensure comments are sent at least to coordinators
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Ensure comments are sent at least to coordinators
- Date: Sat, 18 Apr 2015 10:28:04 +0000 (UTC)
commit 527597856b213a0cfc52b62ccd9da7428631e654
Author: Claude Paroz <claude 2xlibre net>
Date: Sat Apr 18 12:14:07 2015 +0200
Ensure comments are sent at least to coordinators
Fixes #732889. Thanks Daniel Mustieles for the report.
vertimus/models.py | 3 +++
vertimus/tests/tests.py | 16 +++++++++++-----
2 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/vertimus/models.py b/vertimus/models.py
index afe2e52..3404527 100644
--- a/vertimus/models.py
+++ b/vertimus/models.py
@@ -464,6 +464,9 @@ class Action(ActionAbstract):
# If the action is normally sent to ML (but unchecked) or if the form
# contains a comment, send message to state participants
recipients = set(state.involved_persons().exclude(pk=self.person.pk).values_list('email',
flat=True))
+ if self.comment and not recipients:
+ # In any case, the coordinators should be aware of comments
+ recipients = [pers.email for pers in state.language.team.get_coordinators() if pers.email]
self.send_mail_new_state(state, recipients)
def get_previous_action_with_po(self):
diff --git a/vertimus/tests/tests.py b/vertimus/tests/tests.py
index 7abd4a8..e4d0f04 100644
--- a/vertimus/tests/tests.py
+++ b/vertimus/tests/tests.py
@@ -219,12 +219,13 @@ class VertimusTest(TeamsAndRolesTests):
action = Action.new_by_name('WC', person=self.pt)
action.apply_on(state, {'send_to_ml': action.send_mail_to_ml, 'comment': "Hi!"})
- self.assertEqual(len(mail.outbox), 0)
+ self.assertEqual(len(mail.outbox), 1)
+ self.assertEqual(mail.outbox[0].recipients(), [self.l.team.get_coordinators()[0].email])
# Second comment by someone else, mail sent to the other person
action = Action.new_by_name('WC', person=self.pr)
action.apply_on(state, {'send_to_ml': action.send_mail_to_ml, 'comment': "Great!"})
- self.assertEqual(len(mail.outbox), 1)
- self.assertEqual(mail.outbox[0].recipients(), [self.pt.email])
+ self.assertEqual(len(mail.outbox), 2)
+ self.assertEqual(mail.outbox[1].recipients(), [self.pt.email])
# Test that submitting a comment without text generates a validation error
form = ActionForm(state, [ActionWC()], True, QueryDict('action=WC&comment='))
self.assertTrue("A comment is needed" in str(form.errors))
@@ -282,7 +283,7 @@ class VertimusTest(TeamsAndRolesTests):
action = Action.new_by_name('RP', person=self.pr)
action.apply_on(state, {
- 'send_to_ml': action.send_mail_to_ml, 'comment': "Reserved by a reviewer!",
+ 'send_to_ml': action.send_mail_to_ml, 'comment': "",
})
self.assertTrue(isinstance(state, StateProofreading))
self.assertEqual(len(mail.outbox), 0)
@@ -291,10 +292,15 @@ class VertimusTest(TeamsAndRolesTests):
state = StateTranslated.objects.create(branch=self.b, domain=self.d, language=self.l)
action = Action.new_by_name('WC', person=self.pt)
action.apply_on(state, {'send_to_ml': False, 'comment': "Hi!"})
+ # At least the coordinator receives the message
+ self.assertEqual(len(mail.outbox), 1)
+ self.assertEqual(mail.outbox[0].recipients(), [self.l.team.get_coordinators()[0].email])
+
action = Action.new_by_name('RP', person=self.pr)
action.apply_on(state, {'send_to_ml': False, 'comment': "I'm reviewing this!"})
# If a comment is set, a message should be sent
- self.assertEqual(len(mail.outbox), 1)
+ self.assertEqual(len(mail.outbox), 2)
+ self.assertEqual(mail.outbox[1].recipients(), [self.pt.email])
def test_action_up(self):
state = StateProofreading(branch=self.b, domain=self.d, language=self.l, person=self.pr)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]