correct ajax request
authorcavaliet
Thu, 26 Jun 2014 12:13:41 +0200
changeset 285 f9a7cc377689
parent 284 f01235a1dcc2
child 286 5e98984bbfc9
correct ajax request
src/hdalab/views/ajax.py
--- a/src/hdalab/views/ajax.py	Thu Jun 26 10:44:05 2014 +0200
+++ b/src/hdalab/views/ajax.py	Thu Jun 26 12:13:41 2014 +0200
@@ -219,20 +219,19 @@
     res = []
     
     for t in qslist:
-        dbfields = t.dbpedia_fields
-        resobj = {'original_label':t.label,'nb':t.nb}
-        resobj['thumbnail'] = dbfields.thumbnail if dbfields is not None else None
-        
-#        if t.id in translations and not translations[t.id].get('is_label_translated', True):
-#            continue
-        if t.id in translations:
-            resobj['value'] = translations[t.id]['label']
-            resobj['abstract'] = translations[t.id]['abstract']
-        else:
-            resobj['value'] = t.label
-            resobj['abstract'] = dbfields.abstract if dbfields is not None else None
-        if q is None or resobj['value'].lower().find(lq) != -1:
-            res.append(resobj)
+        if hasattr(t, 'dbpedia_fields'):
+            dbfields = t.dbpedia_fields
+            resobj = {'original_label':t.label,'nb':t.nb}
+            resobj['thumbnail'] = dbfields.thumbnail if dbfields is not None else None
+            
+            if t.id in translations:
+                resobj['value'] = translations[t.id]['label']
+                resobj['abstract'] = translations[t.id]['abstract']
+            else:
+                resobj['value'] = t.label
+                resobj['abstract'] = dbfields.abstract if dbfields is not None else None
+            if q is None or resobj['value'].lower().find(lq) != -1:
+                res.append(resobj)
     
     return HttpResponse(content=json.dumps(res), mimetype='application/json')