Commit 7a726ea7 authored by Michal Čihař's avatar Michal Čihař

Let project owner receive merge failures

Issue #636
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 376fc38f
......@@ -50,8 +50,15 @@ def notify_merge_failure(subproject, error, status):
subscriptions = Profile.objects.subscribed_merge_failure(
subproject.project,
)
users = set()
for subscription in subscriptions:
subscription.notify_merge_failure(subproject, error, status)
users.add(subscription.user_id)
if subproject.project.owner and subproject.project.owner_id not in users:
subproject.project.owner.profile.notify_merge_failure(
subproject, error, status
)
# Notify admins
send_notification_email(
......
......@@ -425,10 +425,12 @@ class NotificationTest(ViewTestCase):
profile.save()
def second_user(self):
return User.objects.create_user(
user = User.objects.create_user(
username='seconduser',
password='secondpassword'
)
Profile.objects.create(user=user)
return user
def test_notify_merge_failure(self):
notify_merge_failure(
......@@ -444,6 +446,17 @@ class NotificationTest(ViewTestCase):
'[Weblate] Merge failure in Test/Test'
)
# Add project owner
self.subproject.project.owner = self.second_user()
notify_merge_failure(
self.subproject,
'Failed merge',
'Error\nstatus'
)
# Check mail (second one is for admin)
self.assertEqual(len(mail.outbox), 5)
def test_notify_new_string(self):
notify_new_string(self.get_translation())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment