--- a/src/jocondelab/__init__.py Fri Jan 17 18:26:16 2014 +0100
+++ b/src/jocondelab/__init__.py Mon Jan 20 11:22:52 2014 +0100
@@ -1,4 +1,4 @@
-VERSION = (0, 49, 0, "final", 0)
+VERSION = (0, 50, 0, "final", 0)
def get_version():
--- a/src/jocondelab/views/front_office.py Fri Jan 17 18:26:16 2014 +0100
+++ b/src/jocondelab/views/front_office.py Mon Jan 20 11:22:52 2014 +0100
@@ -136,7 +136,7 @@
fs = list(DbpediaFields.objects.filter(label__in=queryterms, language_code=lang))
# If fs is empty, qs has to be empty
if len(fs)==0:
- qs = EmptyQuerySet()
+ qs = qs.none()
fields_hash = {}
for fields in fs:
@@ -170,7 +170,7 @@
context["searchterms_input"] = u";".join(searchterms)
context["uri_cache"] = json.dumps(uri_cache)
- if type(qs) == EmptyQuerySet:
+ if isinstance(qs, EmptyQuerySet):
context["page_count"] = 0
context["count"] = 0
ns = []
@@ -359,6 +359,7 @@
tqs = tqs.filter(thesaurus__label__in=['REPR','SREP'])
else:
tqs = tqs.filter(thesaurus__label=thesaurus)
+ img_dict = {}
if alpha_sort:
# Particular case in which thesaurus == AUTR and the alphabet is latin,
# we use original sorting by family name
@@ -375,16 +376,17 @@
if uri not in known_uris:
terms.append(t)
known_uris.append(uri)
+ if t["image_url"]:
+ img_dict[t["dbpedia_uri"]] = t["image_url"]
else:
# First optimised query with sum of nb of notices
terms = tqs.values('dbpedia_uri','dbpedia_fields__abstract','dbpedia_fields__label').annotate(num_not=Sum('nb_illustrated_notice')).order_by('-num_not')[:60]
# Second query to get images and create dict dbpedia_uri:image_url
img_qs = self.image_extra(Term.objects.filter(dbpedia_uri__in=[t['dbpedia_uri'] for t in terms])).values_list('dbpedia_uri','image_url') # @UndefinedVariable
# Build img_dict by avoiding None values
- img_dict = {}
for (uri,img) in img_qs:
if img:
- img_dict[uri] = img
+ img_dict[uri] = img
# Build term list
terms = [{
"dbpedia_uri": t['dbpedia_uri'],