Commit 6beaf723 by Nicolas Joyard

Gestion last mod sur job amendements

parent 4d86c6ea
......@@ -24,7 +24,8 @@ class ImportAmendementsJob(BaseANJob):
def save_texte(self, json):
self.current = u'Texte %s' % json['refTexteLegislatif']
document = self.get_cached(Document, json['refTexteLegislatif'])
document = self.save(Document, json['refTexteLegislatif'])
amendements = json['amendements']['amendement']
if isinstance(amendements, dict):
......@@ -35,56 +36,57 @@ class ImportAmendementsJob(BaseANJob):
def save_amendement(self, json, document):
self.current = u'Amendement %s' % json['uid']
am = self.get_cached(Amendement, json['uid'])
am.document = document
id = json['identifiant']
am.numero = int(id['numero'])
am.num_rect = int(id['numRect'])
am.organe = self.get_cached(Organe, id['saisine']['organeExamen'])
am.legislature = self.get_cached(Legislature, int(id['legislature']))
am.numero_long = json['numeroLong']
am.etape_texte = json['etapeTexte']
am.tri = json['triAmendement']
am.cardinal_multiples = int(json['cardinaliteAmdtMultiples'])
fr = json['pointeurFragmentTexte']
dv = fr['division']
co = json['corps']
lo = json['loiReference']
if json.get('amendementParent', None):
am.amendement_parent = \
self.get_cached(Amendement, json['amendementParent'])
data = {
'amendement_parent': None,
'article_99': int(json['article99']) > 0,
'cardinal_multiples': int(json['cardinaliteAmdtMultiples']),
'code_loi': lo['codeLoi'],
'code_loi_division': lo['divisionCodeLoi'],
'corps_dispositif': co.get('dispositif', None),
'corps_expose': co.get('exposeSommaire', None),
'date_depot': self.parse_date(json['dateDepot']),
'date_distribution': self.parse_date(json['dateDistribution']),
'date_sort': None,
'division_alinea': None,
'division_alinea_position': None,
'division_article_additionnel': dv.get('articleAdditionnel', '0') != '0',
'division_chapitre_additionnel': dv.get('chapitreAdditionnel', '0') != '0',
'division_position': dv['avant_A_Apres'],
'division_texte': dv['titre'],
'document': document,
'etape_texte': json['etapeTexte'],
'etat': json['etat'],
'legislature': self.save(Legislature, int(id['legislature'])),
'num_rect': int(id['numRect']),
'numero': int(id['numero']),
'numero_long': json['numeroLong'],
'organe': self.save(Organe, id['saisine']['organeExamen']),
'sort': None,
'tri': json['triAmendement'],
}
am.etat = json['etat']
am.article_99 = int(json['article99']) > 0
if json.get('amendementParent', None):
data['amendement_parent'] = \
self.save(Amendement, json['amendementParent'])
so = json['sort']
if so:
am.sort = so['sortEnSeance']
am.date_sort = self.parse_date(so['dateSaisie'])
data['sort'] = so['sortEnSeance']
data['date_sort'] = self.parse_date(so['dateSaisie'])
fr = json['pointeurFragmentTexte']
dv = fr['division']
am.division_texte = dv['titre']
am.division_position = dv['avant_A_Apres']
am.division_chapitre_additionnel = \
dv.get('chapitreAdditionnel', '0') != '0'
am.division_article_additionnel = \
dv.get('articleAdditionnel', '0') != '0'
al = fr['alinea']
if al and al.get('numero', None):
am.division_alinea = int(al['numero'])
am.division_alinea_position = al['avant_A_Apres']
co = json['corps']
am.corps_dispositif = co.get('dispositif', None)
am.corps_expose = co.get('exposeSommaire', None)
lo = json['loiReference']
am.code_loi = lo['codeLoi']
am.code_loi_division = lo['divisionCodeLoi']
data['division_alinea'] = int(al['numero'])
data['division_alinea_position'] = al['avant_A_Apres']
am.date_depot = self.parse_date(json['dateDepot'])
am.date_distribution = self.parse_date(json['dateDistribution'])
am = self.save(Amendement, json['uid'], data)
def run(app, force=False, file=None):
......
......@@ -238,6 +238,7 @@ class Document(db.Model):
__tablename__ = 'documents'
query_class = SearchableQuery
_last_modified = db.Column(db.DateTime)
id = db.Column(db.Unicode, primary_key=True)
date_creation = db.Column(db.Date)
......@@ -372,6 +373,7 @@ class Amendement(db.Model):
__tablename__ = 'amendements'
query_class = SearchableQuery
_last_modified = db.Column(db.DateTime)
id = db.Column(db.Unicode, primary_key=True)
numero = db.Column(db.Integer)
......
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