Commit ce6bd115 authored by Nicolas Joyard's avatar Nicolas Joyard
Browse files

Update recommendations imports

parent 8c194430
......@@ -11,5 +11,16 @@ dossier_mappings = {
"Rapport Lambrinidis on strengthening security and fundamental freedoms on the Internet":
"Strengthening security and fundamental freedoms on the Internet",
"Criminal measures aimed at ensuring the enforcement of intellectual property rights (IPRED 2), 1st reading":
"Criminal measures aimed at ensuring the enforcement of intellectual property rights"
"Criminal measures aimed at ensuring the enforcement of intellectual property rights",
"A7-0204/2012":
"EU/Australia, Canada, Japan, Korea, Mexico, Morocco, New Zealand, Singapore, Switzerland and United States Anti-Counterfeiting Trade Agreement (ACTA)",
"A7-0001/2012":
"Enhanced cooperation in the area of the creation of unitary patent protection: implementation"
}
resolutions = [
u'résolution législative',
u'résolution',
'legislative resolution',
'resolution'
]
......@@ -9,7 +9,7 @@ import sys
from representatives_recommendations.models import Recommendation
from representatives_votes.models import Dossier, Proposal
from .dossier_mappings import dossier_mappings
from .import_data import dossier_mappings, resolutions
logger = logging.getLogger(__name__)
......@@ -35,10 +35,21 @@ class RecommendationImporter:
return dossier
def get_proposal(self, dossier, kind):
kinds = [kind]
try:
return Proposal.objects.get(dossier=dossier, kind__iexact=kind)
except Proposal.DoesNotExist:
return None
resolutions.index(kind.lower())
kinds.extend(resolutions)
except ValueError:
pass
for k in kinds:
try:
return Proposal.objects.get(dossier=dossier, kind__iexact=k)
except Proposal.DoesNotExist:
continue
return None
def import_row(self, row):
dossier = self.get_dossier(row['title'])
......
Supports Markdown
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