src/ldt/ldt/ldt_utils/views/front.py
changeset 446 2fdfe3ee9498
parent 445 ba508b671698
child 452 8e9494006e7b
--- a/src/ldt/ldt/ldt_utils/views/front.py	Wed Jan 25 14:25:53 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/views/front.py	Wed Jan 25 14:50:22 2012 +0100
@@ -133,39 +133,29 @@
         return Tag.objects.cloud_for_model(Content, steps=steps)[:limit]
 
 
-def annotation_preview(request, content_iri_id, project_id, cutting_id, annot_id):
+def annotation_preview(request, project_id, content_id, ensemble_id, cutting_id, segment_id):
     
     if project_id == '_':
         project_id = ''
     
-    s = Segment.objects.filter(iri_id=content_iri_id, project_id=project_id, cutting_id=cutting_id, element_id=annot_id )
+    s = get_object_or_404(Segment, iri_id=content_id, project_id=project_id, cutting_id=cutting_id, element_id=segment_id, ensemble_id=ensemble_id)
+ 
+    annotation = {
+                  'project_id': s.project_id,
+                  'iri_id' : s.iri_id,
+                  'ensemble_id' : s.ensemble_id, 
+                  'cutting_id' : s.cutting_id,
+                  'element_id' : s.ensemble_id,
+                  'tags' : s.tags,
+                  'title': s.title,
+                  'duration': s.duration, 
+                  'start_ts': s.start_ts, 
+                  'author': s.author,
+                  'date': s.date, 
+                  'abstract': s.abstract                     
+                  }        
     
-    if not s:
-        annotation = {}
-    else:    
-        s = s[0]
-        annotation = {
-                    'project_id': s.project_id,
-                    'iri_id' : s.iri_id,
-                    'ensemble_id' : s.ensemble_id, 
-                    'cutting_id' : s.cutting_id,
-                    'element_id' : s.ensemble_id,
-                    'tags' : s.tags,
-                    'title': s.title,
-                    'duration': s.duration, 
-                    'start_ts': s.start_ts, 
-                    'author': s.author,
-                    'date': s.date, 
-                    'abstract': s.abstract                     
-                    }        
-    
-    mimetype = request.REQUEST.get("mimetype")
-    if mimetype is None:
-        mimetype = "application/json; charset=utf-8"
-    else:
-        mimetype = mimetype.encode("utf-8")
-    if "charset" not in mimetype:
-        mimetype += "; charset=utf-8" 
+    mimetype = "application/json; charset=utf-8"
     resp = HttpResponse(mimetype=mimetype)
     resp['Cache-Control'] = 'no-cache, must-revalidate'
     resp['Pragma'] = 'no-cache'