Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
parlapi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
David Guillot
parlapi
Commits
5be488a7
Commit
5be488a7
authored
Apr 15, 2017
by
Nicolas Joyard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feat.amendement_auteur', closes !4
parents
d475c625
59d8473c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
114 additions
and
2 deletions
+114
-2
migrations/versions/0c154fdc1261_.py
migrations/versions/0c154fdc1261_.py
+28
-0
migrations/versions/9312f57cabaf_.py
migrations/versions/9312f57cabaf_.py
+36
-0
parlapi/jobs/an_amendements.py
parlapi/jobs/an_amendements.py
+32
-1
parlapi/models.py
parlapi/models.py
+18
-1
No files found.
migrations/versions/0c154fdc1261_.py
0 → 100644
View file @
5be488a7
"""empty message
Revision ID: 0c154fdc1261
Revises: 9312f57cabaf
Create Date: 2017-04-04 16:21:03.069577
"""
from
alembic
import
op
import
sqlalchemy
as
sa
# revision identifiers, used by Alembic.
revision
=
'0c154fdc1261'
down_revision
=
'9312f57cabaf'
branch_labels
=
None
depends_on
=
None
def
upgrade
():
# ### commands auto generated by Alembic - please adjust! ###
op
.
add_column
(
'amendements'
,
sa
.
Column
(
'auteur_texte_affichable'
,
sa
.
Unicode
(),
nullable
=
True
))
# ### end Alembic commands ###
def
downgrade
():
# ### commands auto generated by Alembic - please adjust! ###
op
.
drop_column
(
'amendements'
,
'auteur_texte_affichable'
)
# ### end Alembic commands ###
migrations/versions/9312f57cabaf_.py
0 → 100644
View file @
5be488a7
"""empty message
Revision ID: 9312f57cabaf
Revises: 55c1e64eaf9f
Create Date: 2017-03-30 14:56:51.669999
"""
from
alembic
import
op
import
sqlalchemy
as
sa
# revision identifiers, used by Alembic.
revision
=
'9312f57cabaf'
down_revision
=
'55c1e64eaf9f'
branch_labels
=
None
depends_on
=
None
def
upgrade
():
# ### commands auto generated by Alembic - please adjust! ###
op
.
create_table
(
'acteurs_amendements'
,
sa
.
Column
(
'id'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'relation'
,
sa
.
Unicode
(),
nullable
=
True
),
sa
.
Column
(
'acteur_id'
,
sa
.
Unicode
(),
nullable
=
True
),
sa
.
Column
(
'amendement_id'
,
sa
.
Unicode
(),
nullable
=
True
),
sa
.
ForeignKeyConstraint
([
'acteur_id'
],
[
'acteurs.id'
],
),
sa
.
ForeignKeyConstraint
([
'amendement_id'
],
[
'amendements.id'
],
),
sa
.
PrimaryKeyConstraint
(
'id'
)
)
# ### end Alembic commands ###
def
downgrade
():
# ### commands auto generated by Alembic - please adjust! ###
op
.
drop_table
(
'acteurs_amendements'
)
# ### end Alembic commands ###
parlapi/jobs/an_amendements.py
View file @
5be488a7
...
...
@@ -2,7 +2,7 @@
from
.base
import
BaseANJob
from
.utils
import
ijson_items
from
..models
import
A
cteur
,
Amendement
,
Document
,
Legislature
,
Organe
from
..models
import
A
mendement
,
Acteur
Amendement
,
Document
,
Legislature
,
Organe
class
ImportAmendementsJob
(
BaseANJob
):
...
...
@@ -42,6 +42,7 @@ class ImportAmendementsJob(BaseANJob):
dv
=
fr
[
'division'
]
co
=
json
[
'corps'
]
lo
=
json
[
'loiReference'
]
si
=
json
[
'signataires'
]
data
=
{
'amendement_parent'
:
None
,
...
...
@@ -70,12 +71,42 @@ class ImportAmendementsJob(BaseANJob):
'organe'
:
self
.
save
(
Organe
,
id
[
'saisine'
][
'organeExamen'
]),
'sort'
:
None
,
'tri'
:
json
[
'triAmendement'
],
'auteur_texte_affichable'
:
si
[
'texteAffichable'
],
}
if
json
.
get
(
'amendementParent'
,
None
):
data
[
'amendement_parent'
]
=
\
self
.
save
(
Amendement
,
json
[
'amendementParent'
])
signataires
=
[]
auteur
=
si
[
'auteur'
]
auteur_ref
=
None
if
'acteurRef'
in
auteur
and
auteur
[
'acteurRef'
]:
auteur_ref
=
auteur
[
'acteurRef'
]
aa
=
ActeurAmendement
(
relation
=
u'auteur'
)
aa
.
acteur_id
=
auteur_ref
signataires
.
append
(
aa
)
cosignataires
=
si
[
'cosignataires'
]
if
cosignataires
:
if
'acteurRef'
not
in
cosignataires
:
cosignataires
=
[]
else
:
cosignataires
=
cosignataires
[
'acteurRef'
]
if
isinstance
(
cosignataires
,
basestring
):
cosignataires
=
[
cosignataires
]
for
cosignataire
in
cosignataires
:
if
auteur_ref
and
cosignataire
==
auteur_ref
:
continue
acs
=
ActeurAmendement
(
relation
=
u'cosignataire'
)
acs
.
acteur_id
=
cosignataire
signataires
.
append
(
acs
)
data
[
'signataires'
]
=
signataires
so
=
json
[
'sort'
]
if
so
:
data
[
'sort'
]
=
so
[
'sortEnSeance'
]
...
...
parlapi/models.py
View file @
5be488a7
...
...
@@ -170,6 +170,7 @@ class Acteur(db.Model):
mandats
=
db
.
relationship
(
'Mandat'
,
back_populates
=
'acteur'
)
documents
=
db
.
relationship
(
'ActeurDocument'
,
back_populates
=
'acteur'
)
dossiers
=
db
.
relationship
(
'ActeurDossier'
,
back_populates
=
'acteur'
)
amendements
=
db
.
relationship
(
'ActeurAmendement'
,
back_populates
=
'acteur'
)
search_vector
=
db
.
Column
(
TSVectorType
(
'civilite'
,
'nom'
,
'prenom'
,
'profession'
))
...
...
@@ -407,8 +408,9 @@ class Amendement(db.Model):
date_depot
=
db
.
Column
(
db
.
Date
)
date_distribution
=
db
.
Column
(
db
.
Date
)
auteur_texte_affichable
=
db
.
Column
(
db
.
Unicode
)
# TODO référence séance json['seanceDiscussion']
# TODO auteurs/cosignataires
legislature_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'legislatures.id'
))
legislature
=
db
.
relationship
(
'Legislature'
,
back_populates
=
'amendements'
)
...
...
@@ -424,11 +426,26 @@ class Amendement(db.Model):
backref
=
db
.
backref
(
'amendement_parent'
,
remote_side
=
[
id
]))
signataires
=
db
.
relationship
(
'ActeurAmendement'
,
back_populates
=
'amendement'
)
search_vector
=
db
.
Column
(
TSVectorType
(
'numero_long'
,
'corps_expose'
,
'corps_dispositif'
,
'code_loi'
,
'code_loi_division'
))
class
ActeurAmendement
(
db
.
Model
):
__tablename__
=
'acteurs_amendements'
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
relation
=
db
.
Column
(
db
.
Unicode
)
acteur_id
=
db
.
Column
(
db
.
Unicode
,
db
.
ForeignKey
(
'acteurs.id'
))
acteur
=
db
.
relationship
(
'Acteur'
,
back_populates
=
'amendements'
)
amendement_id
=
db
.
Column
(
db
.
Unicode
,
db
.
ForeignKey
(
'amendements.id'
))
amendement
=
db
.
relationship
(
'Amendement'
,
back_populates
=
'signataires'
)
class
Scrutin
(
db
.
Model
):
__tablename__
=
'scrutins'
query_class
=
SearchableQuery
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment