[damned-lies] Fixed #222 - Always send to mailing list when posting through API
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Fixed #222 - Always send to mailing list when posting through API
- Date: Tue, 6 Apr 2021 07:32:52 +0000 (UTC)
commit a9b172544266d58dfbb5f1ca9c144cef43a963bf
Author: Claude Paroz <claude 2xlibre net>
Date: Tue Apr 6 09:31:28 2021 +0200
Fixed #222 - Always send to mailing list when posting through API
api/tests.py | 11 +++++++++--
api/views.py | 4 ++--
2 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/api/tests.py b/api/tests.py
index 904501f5..fcd274d6 100644
--- a/api/tests.py
+++ b/api/tests.py
@@ -1,5 +1,6 @@
from pathlib import Path
+from django.core import mail
from django.core.files import File
from django.test import TestCase
from django.urls import reverse
@@ -109,7 +110,8 @@ class APITests(TestCase):
first_name='John', last_name='Translator',
email='jt devnull com', username='translator'
)
- Role.objects.create(team=Team.objects.get(name='fr'), person=translator)
+ team = Team.objects.get(name='fr')
+ Role.objects.create(team=team, person=translator)
url = reverse('api-reserve', args=['gnome-hello', 'master', 'po', 'fr'])
# Test anonymous cannot post
response = self.client.post(url, data={})
@@ -118,6 +120,8 @@ class APITests(TestCase):
self.client.force_login(translator)
response = self.client.post(url, data={})
self.assertEqual(response.json(), {'result': 'OK'})
+ self.assertEqual(len(mail.outbox), 1)
+ self.assertEqual(mail.outbox[0].recipients(), [team.mailing_list])
state = State.objects.get(person=translator)
self.assertEqual(state.name, 'Translating')
@@ -126,7 +130,8 @@ class APITests(TestCase):
first_name='John', last_name='Translator',
email='jt devnull com', username='translator'
)
- Role.objects.create(team=Team.objects.get(name='fr'), person=translator)
+ team = Team.objects.get(name='fr')
+ Role.objects.create(team=team, person=translator)
_, _, state = get_vertimus_state(
Branch.objects.get(module__name='gnome-hello'),
Domain.objects.get(module__name='gnome-hello', name='po'),
@@ -148,3 +153,5 @@ class APITests(TestCase):
with (test_po).open('rb') as fh:
response = self.client.post(url, data={'file': File(fh)})
self.assertEqual(response.json(), {'result': 'OK'})
+ self.assertEqual(len(mail.outbox), 1)
+ self.assertEqual(mail.outbox[0].recipients(), [team.mailing_list])
diff --git a/api/views.py b/api/views.py
index 1f2d57c7..fe5b279e 100644
--- a/api/views.py
+++ b/api/views.py
@@ -223,7 +223,7 @@ class ReserveTranslationView(LoginRequiredMixin, VertimusPageMixin, View):
raise PermissionDenied('This module cannot be reserved')
action = ActionRT(person=request.user.person)
- action.apply_on(state, {'comment': ''})
+ action.apply_on(state, {'comment': '', 'send_to_ml': True})
return JsonResponse({'result': 'OK'})
@@ -236,7 +236,7 @@ class UploadTranslationView(LoginRequiredMixin, VertimusPageMixin, View):
raise PermissionDenied('You cannot upload a translation to this module')
action = ActionUT(person=request.user.person, file=request.FILES.get('file'))
- action.apply_on(state, {'comment': ''})
+ action.apply_on(state, {'comment': '', 'send_to_ml': True})
return JsonResponse({'result': 'OK'})
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]