diff --git a/synchro_orleans/data/management/commands/email_new_invoices.py b/synchro_orleans/data/management/commands/email_new_invoices.py index bb76fd3..338c4e5 100644 --- a/synchro_orleans/data/management/commands/email_new_invoices.py +++ b/synchro_orleans/data/management/commands/email_new_invoices.py @@ -3,6 +3,7 @@ import json import shutil import os import requests +import logging from django.core.management.base import BaseCommand, CommandError from django.conf import settings @@ -19,6 +20,8 @@ from synchro_orleans import signature notification_timeout = settings.INVOICES_NOTIFICATION_TIMEOUT invoice_view_url_base = settings.INVOICE_VIEW_URL_BASE +logger = logging.getLogger(__name__) + class Command(BaseCommand): help = """ @@ -47,6 +50,7 @@ class Command(BaseCommand): url = '{url}/{nameid}?{query}'.format(url=settings.AUTHENTIC2_USER_INFO_URL, nameid=nameid.name_id, query=signed_query) + logger.debug('requesting: %s' % url) response = requests.get(url) data = response.json() attachment = os.path.join(settings.INVOICES_DIR, 'facture_%s.pdf' % invoice.id) @@ -60,6 +64,7 @@ class Command(BaseCommand): message = EmailMultiAlternatives(self.email_subject, text_body, self.email_from, [result.email]) message.attach_file(os.path.join(settings.INVOICES_DIR, 'facture_%s.pdf'% invoice.id)) message.send() + logger.debug('email for invoice nr. %s sent' % invoice.id) invoice.date_envoi_dernier_mail = make_aware(datetime.now(), get_current_timezone()) InvoiceNotificationEmail.objects.create(invoice_number=invoice.id)