Add cutting_id to search results
authorverrierj
Wed, 25 Jan 2012 14:50:22 +0100
changeset 446 2fdfe3ee9498
parent 445 ba508b671698
child 449 57db78aa084f
child 451 ff060d157dae
Add cutting_id to search results
src/ldt/ldt/ldt_utils/templates/front/front_search_results.html
src/ldt/ldt/ldt_utils/urls.py
src/ldt/ldt/ldt_utils/views/front.py
--- a/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html	Wed Jan 25 14:25:53 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html	Wed Jan 25 14:50:22 2012 +0100
@@ -28,6 +28,9 @@
                     "id" : '{{segment.element_id}}',
                     "begin" : {{segment.begin}},
                     "duration" : {{segment.duration}},
+                    "cutting_id" : '{{segment.decoupage_id}}',
+                    "project_id" : '{{segment.project_id}}',
+                    "ensemble_id" : '{{segment.ensemble_id}}',
                 },{% endfor %}
             ],
             "stats" : [{{ res.content.stat_annotation }}],
@@ -35,7 +38,9 @@
     ];
     
     var global_csrf_token = "{{ csrf_token }}";
-    var annot_preview_url = "{% url ldt.ldt_utils.views.front.annotation_preview content_iri_id='__CONTENT_IRI_ID__' project_id='__PROJECT_ID__' cutting_id='__CUTTING_ID__' annot_id='__ANNOT_ID__' %}";
+    var annot_preview_url = "{% url ldt.ldt_utils.views.front.annotation_preview project_id='__PROJECT_ID__' content_id='__CONTENT_ID__' ensemble_id='__ENSEMBLE_ID__' cutting_id='__CUTTING_ID__' segment_id='__SEGMENT_ID__' %}";
+
+    
 </script>
 <script src="{{LDT_MEDIA_PREFIX}}js/Ldt_front_search_results.js" type="text/javascript"></script>
 
--- a/src/ldt/ldt/ldt_utils/urls.py	Wed Jan 25 14:25:53 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/urls.py	Wed Jan 25 14:50:22 2012 +0100
@@ -48,7 +48,7 @@
     url(r'^front/search/$', 'views.front.search_index'),
     url(r'^front/searchListing', 'views.front.search_listing'),
     url(r'^front/medias', 'views.front.all_contents'),
-    url(r'^annotpreview/(?P<content_iri_id>.*)/(?P<project_id>.*)/(?P<cutting_id>.*)/(?P<annot_id>.*)$', 'views.front.annotation_preview'),
+    url(r'^annotpreview/(?P<project_id>.*)/(?P<content_id>.*)/(?P<ensemble_id>.*)/(?P<cutting_id>.*)/(?P<segment_id>.*)/$', 'views.front.annotation_preview'),
 )
 
 urlpatterns += patterns('',
--- 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'