web/hdalab/views/ajax.py
changeset 132 e6483309fa52
parent 131 9d5d9e6b7fbf
child 133 e821a1ae9773
--- a/web/hdalab/views/ajax.py	Tue Feb 28 18:51:58 2012 +0100
+++ b/web/hdalab/views/ajax.py	Wed Feb 29 16:14:01 2012 +0100
@@ -99,9 +99,9 @@
     tag_count = request.GET.get('tagcount', 30)
     cont_count = 0
     
-    globalids = []
+    matchtagids = []
     
-    tagqs = Tag.objects.exclude(category__label = u"Localisation").exclude(category__label = u"Datation").exclude(category__label = u"Discipline artistique")
+    tagqs = Tag.objects.exclude(category__label__in = ['Datation', 'Localisation', 'Discipline artistique'])
     countryqs = Country.objects
     discqs = Tag.objects.filter(category__label = u'Discipline artistique')
     yearqs = TagYears.objects
@@ -117,26 +117,26 @@
             delta = max(1, (end_year-start_year)/2)
             minstart = start_year - delta
             maxend = end_year + delta
-            tagqs = Tag.objects.filter(years__end_year__gte = start_year, 
+            matchtagqs = Tag.objects.filter(years__end_year__gte = start_year, 
                                        years__start_year__lte = end_year,
                                        years__end_year__lte = maxend,
                                        years__start_year__gte = minstart)
-            globalids += [t.id for t in tagqs]
-            contentqs = contentqs.filter(taggedsheet__tag__in = tagqs,
+            matchtagids += [t.id for t in matchtagqs]
+            contentqs = contentqs.filter(taggedsheet__tag__in = matchtagqs,
                            taggedsheet__order__lte = max_tag_order)
             
         if label:
             for txtlbl in label.split(","):
-                taglblqs = Tag.objects.filter(label__iexact = txtlbl)
-                globalids += [t.id for t in taglblqs if t.id not in globalids]
-                contentqs = contentqs.filter(taggedsheet__tag__in = taglblqs,
+                matchtagqs = Tag.objects.filter(label__iexact = txtlbl)
+                matchtagids += [t.id for t in matchtagqs if t.id not in matchtagids]
+                contentqs = contentqs.filter(taggedsheet__tag__in = matchtagqs,
                                taggedsheet__order__lte = max_tag_order)
                     
         if country:
             for country_uri in country.split(","):
-                taglblqs = Tag.objects.filter(locatedin__country__dbpedia_uri = country_uri)
-                globalids += [t.id for t in taglblqs if t.id not in globalids]
-                contentqs = contentqs.filter(taggedsheet__tag__in = taglblqs,
+                matchtagqs = Tag.objects.filter(locatedin__country__dbpedia_uri = country_uri)
+                matchtagids += [t.id for t in matchtagqs if t.id not in matchtagids]
+                contentqs = contentqs.filter(taggedsheet__tag__in = matchtagqs,
                                taggedsheet__order__lte = max_tag_order)
         if contentlist:
             contentqs = contentqs.filter(id__in = contentlist.split(","))
@@ -160,7 +160,7 @@
     
     qs = TaggedSheet.objects.select_related('tag').filter(datasheet__in = contentids, order__lte = max_tag_order).order_by('order')
     for ts in qs:
-        match_tag = ts.tag.id in globalids
+        match_tag = ts.tag.id in matchtagids
         contenus[ts.datasheet.id]['tags'].append({'id': ts.tag.id, 'label':ts.tag.label, 'order':ts.order, 'match': match_tag })
         
         if match_tag: