Commit 22e8fcbc authored by Nicolas Joyard's avatar Nicolas Joyard

Francedata: fix social website import

parent 46a9c5c5
# 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
......
[
{
"fields": {
"photo": "http://www.nosdeputes.fr/depute/photo/bernard-roman",
"last_name": "Roman",
"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-assouline",
"last_name": "Assouline",
"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": {
......
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 to comment