--- a/src/hdalab/views/ajax.py Fri Aug 29 16:19:31 2014 +0200
+++ b/src/hdalab/views/ajax.py Tue Sep 02 12:14:38 2014 +0200
@@ -98,12 +98,8 @@
master_category = WpCategory.objects.filter(label__iexact=label)[0:1]
if len(master_category):
resobj = subcat(master_category[0], globtags, 1, MAX_LEVEL )
-
-# tag_list = [k for k in globtags]
-
-# if len(tag_list):
- contents = []
-# datasheets = Datasheet.objects.filter(validated = True, taggedsheet__tag__label__in = tag_list, taggedsheet__order__lte = MAX_TAG_ORDER).distinct()
+
+ #datasheets = Datasheet.objects.filter(validated = True, taggedsheet__tag__label__in = tag_list, taggedsheet__order__lte = MAX_TAG_ORDER).distinct()
datasheets = Datasheet.objects.filter(validated = True, taggedsheet__tag__label__iexact = label, taggedsheet__order__lte = ROOT_MAX_TAG_ORDER).select_related('organisation').distinct()
for datasheet in datasheets:
# Calculating where we add the datasheet in the tree
@@ -133,8 +129,6 @@
'score': max(dsscore, rootscore)
})
cleantags(resobj)
-
-# resobj['contents'] = [{'id': d.id, 'title': d.title, 'tags': [t.label for t in d.tags.filter(taggedsheet__order__lte=5)]} for d in datasheets]
return HttpResponse(content=json.dumps(resobj), mimetype='application/json')
@@ -184,6 +178,10 @@
q = request.GET.get('term',None)
maxcount = int(request.GET.get('count','40'))
lang = request.GET.get('lang',request.LANGUAGE_CODE)
+ count_notices_str = request.REQUEST.get("count_notices")
+ count_notices_bool = True
+ if count_notices_str:
+ count_notices_bool = {'true': True, 'false': False, "0": False, "1": True}.get(count_notices_str.lower())
stemming_langs = [ 'fr', 'en', 'de', 'it' ]
# For Japanese, there are no word boundaries, we should not use the regexp in that case
@@ -205,8 +203,11 @@
qs = qs.filter(dbpedia_fields__translations__label__icontains=q, dbpedia_fields__translations__language_code=lang, dbpedia_fields__translations__is_label_translated = True)
else:
qs = Tag.objects.filter(~Q(dbpedia_uri = None))
-
- qs = qs.annotate(nb=Count('datasheet',distinct=True)).order_by('-nb')[:maxcount]
+
+ if count_notices_bool:
+ qs = qs.annotate(nb=Count('datasheet',distinct=True)).order_by('-nb')[:maxcount]
+ else:
+ qs = qs.distinct()[:maxcount]
qslist = list(qs)
@@ -221,7 +222,9 @@
for t in qslist:
if hasattr(t, 'dbpedia_fields'):
dbfields = t.dbpedia_fields
- resobj = {'original_label':t.label,'nb':t.nb}
+ resobj = {'original_label':t.label, 'url':t.dbpedia_uri}
+ if count_notices_bool:
+ resobj['nb'] = t.nb
resobj['thumbnail'] = dbfields.thumbnail if dbfields is not None else None
if t.id in translations: