ignore cancelled requests (#9871)

This commit is contained in:
Frédéric Péters 2016-02-04 13:47:56 +01:00
parent e25bec5ec9
commit 23e0b423ee
1 changed files with 6 additions and 3 deletions

View File

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
import requests
import urllib
from datetime import datetime, timedelta
@ -32,7 +34,8 @@ class Command(BaseCommand):
filter_query = '?filter=all&filter-date=%s&full=on' % tomorrow.strftime('%Y-%m-%d')
url = getattr(settings, 'ENCOMBRANTS_FORM_URL') + filter_query
r = self.get(url, True)
if not 'err' in r.json():
email_sectors(r.json(), tomorrow)
else:
response = r.json()
if 'err' in response:
raise CommandError('Error while retrieving formdefs: %s' % r.json())
response = [x for x in response if x.get('workflow', {}).get('status', {}).get('name') != u'Annulé']
email_sectors(response, tomorrow)