Correction pb import popularité ; bug #17
authorymh <ymh.work@gmail.com>
Fri, 08 Jul 2011 18:13:36 +0200
changeset 79 949e319fbaa0
parent 78 149cf0d19b10
child 80 15fb85252d88
Correction pb import popularité ; bug #17
web/hdabo/management/commands/import_tag_popularity.py
--- a/web/hdabo/management/commands/import_tag_popularity.py	Fri Jul 08 16:34:01 2011 +0200
+++ b/web/hdabo/management/commands/import_tag_popularity.py	Fri Jul 08 18:13:36 2011 +0200
@@ -10,6 +10,7 @@
 
 from django.core.management.base import BaseCommand, CommandError
 from hdabo.models import Tag
+from hdabo.utils import normalize
 from optparse import make_option
 import csv
 import math
@@ -128,11 +129,10 @@
                                             
                 row = dict([(safe_decode(key, self.encoding), safe_decode(value, self.encoding)) for key, value in row.items()])
                 
-                label = row['label'].strip()
+                label = normalize(row['label'].strip())
                 
                 if not label:
                     continue
-                
-                for tag in Tag.objects.filter(label__iexact=label):
+                for tag in Tag.objects.filter(normalized_label__icontains=label):
                     tag.popularity = int(row['popularity'])
                     tag.save()