Commit 184819a8 authored by Nicolas Joyard's avatar Nicolas Joyard
Browse files

Give a title to untitled recommendations

parent 233f7349
...@@ -24,9 +24,9 @@ class RecommendationImporter: ...@@ -24,9 +24,9 @@ class RecommendationImporter:
if dossier is None: if dossier is None:
ref = dossier_mappings.get(title, None) ref = dossier_mappings.get(title, None)
if ref is not None: if ref is not None:
query = { 'reference':ref } query = {'reference': ref}
else: else:
query = { 'title__iexact': title } query = {'title__iexact': title}
try: try:
dossier = Dossier.objects.get(**query) dossier = Dossier.objects.get(**query)
...@@ -67,6 +67,9 @@ class RecommendationImporter: ...@@ -67,6 +67,9 @@ class RecommendationImporter:
return False return False
weight = int(row['weight']) * int(row['ponderation']) weight = int(row['weight']) * int(row['ponderation'])
descr = row['description'].strip()
if len(descr) == 0:
descr = '%s on %s' % (row['part'], dossier.reference)
try: try:
recom = Recommendation.objects.get(proposal=proposal) recom = Recommendation.objects.get(proposal=proposal)
...@@ -74,7 +77,7 @@ class RecommendationImporter: ...@@ -74,7 +77,7 @@ class RecommendationImporter:
recom = Recommendation( recom = Recommendation(
proposal=proposal, proposal=proposal,
recommendation=row['recommendation'], recommendation=row['recommendation'],
title=row['description'], title=descr,
weight=weight weight=weight
) )
recom.save() recom.save()
......
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