Commit 52f4d92e by Nicolas Joyard

Extract 2

parent 15360c16
Showing with 10 additions and 4 deletions
# -*- coding: utf-8 -*-
from datetime import datetime, timedelta
import dateparser
import email
import os
import re
......@@ -240,6 +241,7 @@ def extraire_mails_cada(app):
with open(os.path.join(emails_root, eml)) as f:
message = email.message_from_file(f)
cada_id = message['subject']
date_avis = dateparser.parse(message['date'].replace(" (CET)", "")
# Extraction pièce jointe 'Avis.pdf'
pdf = None
......@@ -297,6 +299,10 @@ def extraire_mails_cada(app):
if act.attachment != pdfbase:
print('CADA %s; (!) 2ème avis CADA (existant: %s)'
% (cada_id, pdfbase))
if act.date != date_avis:
act.date = date_avis
db.session.add(act)
db.session.commit()
continue
print('CADA %s; Ajout avis CADA pour %s'
......
......@@ -10,7 +10,7 @@ from ..models.constants import (DEBUT_ACTION, ETAPE_A_CONFIRMER,
ETAPE_COURRIEL, ETAPES_BY_ORDRE,
ETAPE_DEMANDE_CADA, ETAPE_DOC_PUBLIE,
ETAPE_REPONSE_NEGATIVE,
ETAPE_DOC_MASQUE, ETAPE_AR_RECU,
ETAPE_DOC_MASQUE, ETAPE_ENVOYE,
ETAPE_REPONSE_POSITIVE, ETAPE_NA)
from .mails import envoyer_alerte
......@@ -121,7 +121,7 @@ def export_pour_ta(app):
.order_by(Parlementaire.nom) \
.all()
output_order = ['num', 'nom', 'sexe', 'refus', 'demande', 'ar',
output_order = ['num', 'nom', 'sexe', 'refus', 'demande', 'bordereau',
'avis_cada']
print(';'.join(output_order))
......@@ -139,8 +139,8 @@ def export_pour_ta(app):
}
for act in parl.actions:
if act.etape == ETAPE_AR_RECU:
data['ar'] = act.attachment
if act.etape == ETAPE_ENVOYE:
data['bordereau'] = act.attachment
if act.etape == ETAPE_REPONSE_NEGATIVE:
data['refus'] = 'REFUS'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment