Little error treatment in search result.
authorcavaliet
Thu, 08 Nov 2012 16:10:08 +0100
changeset 915 5d08847528dd
parent 914 487fd56607e3
child 916 7a614efbaadb
Little error treatment in search result.
src/ldt/ldt/ldt_utils/views/workspace.py
--- a/src/ldt/ldt/ldt_utils/views/workspace.py	Thu Nov 08 16:02:31 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/views/workspace.py	Thu Nov 08 16:10:08 2012 +0100
@@ -40,13 +40,6 @@
 
     is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1);
     
-    # Resolve a URL
-    #project_api_view, project_api_args, project_api_kwargs = resolve('/api/ldt/projects/c8448f21-272d-11e1-876b-c8bcc896c290.json')
-    #match = resolve('/api/ldt/projects/c8448f21-272d-11e1-876b-c8bcc896c290.json')
-    
-    # Print the URL pattern that matches the URL
-    #print match.url_name
-    
     # render list
     return render_to_response("ldt/ldt_utils/workspace.html",
                               {'contents': content_list, 'nb_ct_pages': nb_ct_pages, 'content_nb': content_nb, 'current_content_page':float(num_page),
@@ -261,19 +254,21 @@
                 
         valid_segments = []
         for s in all_related_segments:
-            segment = [seg for seg in all_segments if seg.element_id == s['element_id'] and seg.project_id == s['project_id'] and seg.iri_id == s['iri_id'] and seg.cutting_id == s['cutting_id'] and seg.ensemble_id == s['ensemble_id'] ][0]
-                
-            segment.score = s['score']
-            segment.indexation_id = s['indexation_id']
-            segment.context = s['context']
-            segment.context_tags = s['tags']
-            segment.highlighted = s['highlighted']
-                                    
-            if not s['project_id']:
-                segment.project_id = '_'
-                valid_segments.append(segment)
-            elif s['project_id'] in viewable_projects_id:
-                valid_segments.append(segment)
+            array_of_segs = [seg for seg in all_segments if seg.element_id == s['element_id'] and seg.project_id == s['project_id'] and seg.iri_id == s['iri_id'] and seg.cutting_id == s['cutting_id'] and seg.ensemble_id == s['ensemble_id'] ]
+            if len(array_of_segs)>0:
+                segment = array_of_segs[0]
+                    
+                segment.score = s['score']
+                segment.indexation_id = s['indexation_id']
+                segment.context = s['context']
+                segment.context_tags = s['tags']
+                segment.highlighted = s['highlighted']
+                                        
+                if not s['project_id']:
+                    segment.project_id = '_'
+                    valid_segments.append(segment)
+                elif s['project_id'] in viewable_projects_id:
+                    valid_segments.append(segment)
             
         # If all segments found belong to unpublished projects or projects
         # the current user is not allowed to see