Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Political Memory
django-representatives
Commits
22e8fcbc
Commit
22e8fcbc
authored
Jul 12, 2016
by
Nicolas Joyard
Browse files
Francedata: fix social website import
parent
46a9c5c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
representatives/contrib/francedata/import_representatives.py
View file @
22e8fcbc
# coding: utf-8
import
logging
import
re
import
sys
from
datetime
import
datetime
...
...
@@ -247,7 +248,13 @@ class FranceDataImporter(GenericImporter):
# Websites
websites
=
rep_json
.
get
(
'sites_web'
,
[])
for
site
in
websites
:
if
not
site
[
'site'
].
startswith
(
'http://twitter.com/'
):
if
re
.
search
(
r
'facebook\.com'
,
site
[
'site'
]):
self
.
touch_model
(
model
=
WebSite
,
url
=
site
[
'site'
],
kind
=
'facebook'
,
representative
=
representative
)
elif
not
re
.
search
(
r
'twitter\.com'
,
site
[
'site'
]):
self
.
touch_model
(
model
=
WebSite
,
url
=
site
[
'site'
],
representative
=
representative
...
...
representatives/contrib/francedata/tests/representatives_expected.json
View file @
22e8fcbc
[
{
"fields"
:
{
"
photo"
:
"http://www.nosdeputes.fr/depute/photo/bernard-r
oman"
,
"
last_name"
:
"R
oman"
,
"gender"
:
2
,
"remote_id"
:
"http://www2.assemblee-nationale.fr/deputes/fiche/OMC_PA2611"
,
"first_name"
:
"Bernard"
,
"cv"
:
""
,
"active"
:
true
,
"birth_place"
:
"Lille (Nord)"
,
"first_name"
:
"Bernard"
,
"last_name"
:
"Roman"
,
"full_name"
:
"Bernard Roman"
,
"photo"
:
"http://www.nosdeputes.fr/depute/photo/bernard-roman"
,
"birth_date"
:
"1952-07-15"
,
"slug"
:
"bernard-roman"
},
...
...
@@ -18,15 +18,15 @@
},
{
"fields"
:
{
"
photo"
:
"http://www.nossenateurs.fr/senateur/photo/david-a
ssouline"
,
"
last_name"
:
"A
ssouline"
,
"gender"
:
2
,
"remote_id"
:
"http://www.senat.fr/senateur/assouline_david04059m.html"
,
"first_name"
:
"David"
,
"cv"
:
""
,
"active"
:
true
,
"birth_place"
:
"non disponible"
,
"first_name"
:
"David"
,
"last_name"
:
"Assouline"
,
"full_name"
:
"David Assouline"
,
"photo"
:
"http://www.nossenateurs.fr/senateur/photo/david-assouline"
,
"birth_date"
:
"1959-06-16"
,
"slug"
:
"david-assouline"
},
...
...
@@ -69,15 +69,6 @@
"model"
:
"representatives.website"
,
"pk"
:
1
},
{
"fields"
:
{
"url"
:
"https://twitter.com/bernardroman59"
,
"representative"
:
1
,
"kind"
:
""
},
"model"
:
"representatives.website"
,
"pk"
:
2
},
{
"fields"
:
{
"url"
:
"http://twitter.com/bernardroman59"
,
...
...
@@ -85,7 +76,7 @@
"kind"
:
"twitter"
},
"model"
:
"representatives.website"
,
"pk"
:
3
"pk"
:
2
},
{
"fields"
:
{
...
...
@@ -94,25 +85,16 @@
"kind"
:
""
},
"model"
:
"representatives.website"
,
"pk"
:
4
},
{
"fields"
:
{
"url"
:
"https://twitter.com/dassouline"
,
"representative"
:
2
,
"kind"
:
""
},
"model"
:
"representatives.website"
,
"pk"
:
5
"pk"
:
3
},
{
"fields"
:
{
"url"
:
"https://www.facebook.com/DavAssouline"
,
"representative"
:
2
,
"kind"
:
""
"kind"
:
"
facebook
"
},
"model"
:
"representatives.website"
,
"pk"
:
6
"pk"
:
4
},
{
"fields"
:
{
...
...
@@ -121,7 +103,7 @@
"kind"
:
""
},
"model"
:
"representatives.website"
,
"pk"
:
7
"pk"
:
5
},
{
"fields"
:
{
...
...
@@ -130,7 +112,7 @@
"kind"
:
"twitter"
},
"model"
:
"representatives.website"
,
"pk"
:
8
"pk"
:
6
},
{
"fields"
:
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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