logging added

This commit is contained in:
Serghei Mihai 2014-10-06 17:14:29 +02:00
parent 4e82a97a2e
commit b10d86152c
1 changed files with 5 additions and 0 deletions

View File

@ -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)