src/hdalab/views/ajax.py
changeset 291 44af3e5e4114
parent 290 fb86765b4c54
child 324 573043a98b44
equal deleted inserted replaced
290:fb86765b4c54 291:44af3e5e4114
   396 
   396 
   397         if lang not in no_translate_langs:
   397         if lang not in no_translate_langs:
   398             transqs = DbpediaFieldsTranslation.objects.filter(master__in = dbpediafields.values(), language_code = lang)
   398             transqs = DbpediaFieldsTranslation.objects.filter(master__in = dbpediafields.values(), language_code = lang)
   399             translations = dict([(trans.master_id,trans.label) for trans in transqs])
   399             translations = dict([(trans.master_id,trans.label) for trans in transqs])
   400     
   400     
   401         tags = [{'id': tag.id, 'label': tag.label, 'score': tag.nb, 'translated_label': translations.get(dbpediafields[tag.id].id, tag.label) if tag.id in dbpediafields else tag.label} for tag in tagqslist]
   401         tags = [{'id': tag.id, 'label': tag.label, 'score': tag.nb, 'thumbnail': dbpediafields[tag.id].thumbnail, 'translated_label': translations.get(dbpediafields[tag.id].id, tag.label) if tag.id in dbpediafields else tag.label} for tag in tagqslist]
   402     
   402     
   403         countryqs = countryqs.annotate(nb=Count('includes__tag__taggedsheet'))
   403         countryqs = countryqs.annotate(nb=Count('includes__tag__taggedsheet'))
   404         countries = dict([(country.dbpedia_uri, country.nb) for country in countryqs])
   404         countries = dict([(country.dbpedia_uri, country.nb) for country in countryqs])
   405     
   405     
   406         discqslist = list(discqs.annotate(nb=Count('taggedsheet')).order_by('-nb')[:10])
   406         discqslist = list(discqs.annotate(nb=Count('taggedsheet')).order_by('-nb')[:10])