Commit 16f81773 authored by Michal Čihař's avatar Michal Čihař

Let project owner receive notifications on new language request

Issue #636
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 7a726ea7
...@@ -93,8 +93,15 @@ def notify_new_language(subproject, language, user): ...@@ -93,8 +93,15 @@ def notify_new_language(subproject, language, user):
subproject.project, subproject.project,
user user
) )
users = set()
for subscription in subscriptions: for subscription in subscriptions:
subscription.notify_new_language(subproject, language, user) subscription.notify_new_language(subproject, language, user)
users.add(subscription.user_id)
if subproject.project.owner and subproject.project.owner_id not in users:
subproject.project.owner.profile.notify_new_language(
subproject, language, user
)
# Notify admins # Notify admins
send_notification_email( send_notification_email(
......
...@@ -486,10 +486,11 @@ class NotificationTest(ViewTestCase): ...@@ -486,10 +486,11 @@ class NotificationTest(ViewTestCase):
) )
def test_notify_new_language(self): def test_notify_new_language(self):
second_user = self.second_user()
notify_new_language( notify_new_language(
self.subproject, self.subproject,
Language.objects.filter(code='de'), Language.objects.filter(code='de'),
self.second_user() second_user
) )
# Check mail (second one is for admin) # Check mail (second one is for admin)
...@@ -499,6 +500,17 @@ class NotificationTest(ViewTestCase): ...@@ -499,6 +500,17 @@ class NotificationTest(ViewTestCase):
'[Weblate] New language request in Test/Test' '[Weblate] New language request in Test/Test'
) )
# Add project owner
self.subproject.project.owner = second_user
notify_new_language(
self.subproject,
Language.objects.filter(code='de'),
second_user,
)
# Check mail (second one is for admin)
self.assertEqual(len(mail.outbox), 5)
def test_notify_new_contributor(self): def test_notify_new_contributor(self):
unit = self.get_unit() unit = self.get_unit()
notify_new_contributor( notify_new_contributor(
......
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