lingo: activate localization in new invoices notifications command (#23024)
This commit is contained in:
parent
21c21969f2
commit
be003c355c
|
@ -20,6 +20,7 @@ import logging
|
|||
|
||||
from django.conf import settings
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils import translation
|
||||
|
||||
from combo.apps.lingo.models import Regie
|
||||
|
||||
|
@ -30,6 +31,7 @@ class Command(BaseCommand):
|
|||
if not settings.LINGO_INVOICE_NOTIFICATIONS_ENABLED:
|
||||
return
|
||||
logger = logging.getLogger(__name__)
|
||||
translation.activate(settings.LANGUAGE_CODE)
|
||||
for regie in Regie.objects.exclude(webservice_url=''):
|
||||
try:
|
||||
regie.notify_new_remote_invoices()
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
import pytest
|
||||
import mock
|
||||
|
@ -6,6 +8,7 @@ from decimal import Decimal
|
|||
from requests.exceptions import ConnectionError
|
||||
|
||||
from django.test.client import RequestFactory
|
||||
from django.test import override_settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.conf import settings
|
||||
from django.core.management import call_command
|
||||
|
@ -403,11 +406,13 @@ def test_send_new_remote_invoices_by_email(mock_get, user_saml, admin, app, remo
|
|||
mock_response = mock.Mock(status_code=200, content=json.dumps(FAKE_PENDING_INVOICES))
|
||||
mock_response.json.return_value = FAKE_PENDING_INVOICES
|
||||
mock_get.return_value = mock_response
|
||||
remote_regie.notify_new_remote_invoices()
|
||||
with override_settings(LANGUAGE_CODE='fr'):
|
||||
call_command('notify_new_remote_invoices')
|
||||
|
||||
assert len(mailoutbox) == 1
|
||||
assert mailoutbox[0].recipients() == ['foo@example.net']
|
||||
assert mailoutbox[0].from_email == settings.DEFAULT_FROM_EMAIL
|
||||
assert mailoutbox[0].subject == 'New invoice nr. 01 is available'
|
||||
assert mailoutbox[0].subject == u'Nouvelle facture numéro 01 disponible'
|
||||
html_message = mailoutbox[0].alternatives[0][0]
|
||||
assert 'Combo' in mailoutbox[0].body
|
||||
assert 'Combo' in html_message
|
||||
|
|
Loading…
Reference in New Issue