Search results are clickable
authorverrierj
Thu, 12 Jan 2012 17:56:25 +0100
changeset 382 123b89cf599e
parent 369 271e8d0e251b
child 383 a99ea8eb8b9a
Search results are clickable
src/ldt/ldt/ldt_utils/projectserializer.py
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
src/ldt/ldt/ldt_utils/views/json.py
--- a/src/ldt/ldt/ldt_utils/projectserializer.py	Thu Jan 12 16:25:13 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/projectserializer.py	Thu Jan 12 17:56:25 2012 +0100
@@ -69,18 +69,17 @@
             
             # sets cutting to display in first position for the metadataplayer
             if self.first_cutting:
-                first_cutting = "c_%s" % self.first_cutting.upper()
                 
                 annotation_types = new_display['annotation_types']
                 if len(annotation_types) > 1:
                     index = -1
                     for i, s in enumerate(annotation_types):
-                        if s == first_cutting: 
+                        if s == self.first_cutting: 
                             index = i
                             break
                     if index >= 0:
                         annotation_types[0], annotation_types[index] = annotation_types[index], annotation_types[0]
-                
+            
             self.views_dict[display_id] = new_display
             
     
@@ -165,7 +164,7 @@
                 element_begin = element_node.attrib[u"begin"]
                 element_duration = element_node.attrib[u"dur"]
                 element_media = content.iri_id
-                element_color = element_node.attrib[u"color"]
+                element_color = element_node.attrib.get(u"color", "")
                 element_ldt_src = element_node.attrib.get(u"src", "")
                 
                 element_title = reduce_text_node(element_node, "title/text()")        
@@ -414,22 +413,9 @@
         res['views'] = self.views_dict.values() if len(self.views_dict) > 0 else None
         
         res['annotation-types'] = self.annotation_types_dict.values() if len(self.annotation_types_dict) > 0 else None
-        res['annotations'] = self.annotations_dict.values() if len(self.annotations_dict) > 0 else None 
-
-
-        if self.first_cutting:
-            first_cutting = "c_%s" % self.first_cutting.upper()
-            
-            index = -1
-            for i, ann in enumerate(res['annotation-types']):
-                if ann['id'] == first_cutting:
-                    index = i
-                    break
-                 
-            if index > 0:
-                res['annotation-types'][0],  res['annotation-types'][1] = res['annotation-types'][1],  res['annotation-types'][0]
+        res['annotations'] = self.annotations_dict.values() if len(self.annotations_dict) > 0 else None
         
-        return res
+        return res 
     
     def get_annotations(self, first_cutting=True):
         
--- a/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html	Thu Jan 12 16:25:13 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html	Thu Jan 12 17:56:25 2012 +0100
@@ -21,8 +21,6 @@
 <script type="text/javascript">
     $(document).ready(function () {
         // We draw the annotation volume for each content
-        /* Use 'html' instead of an array of values to pass options 
-        to a sparkline with data in the tag */
         $('.graph_annotation').sparkline('html', {width: '340px',
         										  height:'25px',
         										  minSpotColor: false,
@@ -107,7 +105,7 @@
                             <a href="{% url ldt.ldt_utils.views.lignesdetemps.index_segment segment.project_id segment.iri_id segment.ensemble_id segment.decoupage_id segment.element_id %}"><img src="{{LDT_MEDIA_PREFIX}}img/annot_icon_80x45.png" width="80" height="45" /></a>
                             <!--p class="duree_segment">{{ segment.duration|str_duration:"::" }}</p-->
                         </div>
-                        <h4 class="title_segment"><a class="blue under" href="{% url ldt.ldt_utils.views.lignesdetemps.index_segment segment.project_id segment.iri_id segment.ensemble_id segment.decoupage_id segment.element_id %}">
+                        <h4 class="title_segment"><a class="blue under" href="{% url ldt.ldt_utils.views.front.annot_content segment.iri_id segment.decoupage_id %}">
                           {% if segment.title %}{{ segment.title }}{% else %}{% trans "No title" %}{% endif %}</a></h4>
                         <p class="text_segment">{% if segment.context %}{{ segment.context }}{% endif %}<br/>{% trans "Begin" %} : {{ segment.begin|str_duration:"::" }} - {% trans "duration" %} : {{ segment.duration|str_duration:"::" }}</h4>
                     </li>
--- a/src/ldt/ldt/ldt_utils/urls.py	Thu Jan 12 16:25:13 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/urls.py	Thu Jan 12 17:56:25 2012 +0100
@@ -43,6 +43,7 @@
     url(r'^updateGroup/(?P<group_id>.*)$', 'views.group.update_group'),
     url(r'^front/$', 'views.front.front_home'),
     url(r'^front/group/(?P<group_id>.*)$', 'views.front.group_info'),
+    url(r'^front/playerCutting/(?P<content_iri_id>.*)/(?P<cutting_id>.*)/$', 'views.front.annot_content'),
     url(r'^front/player/(?P<content_iri_id>.*)$', 'views.front.annot_content'),
     url(r'^front/search/$', 'views.front.search_index'),
     url(r'^front/searchListing', 'views.front.search_listing'),
--- a/src/ldt/ldt/ldt_utils/views/front.py	Thu Jan 12 16:25:13 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/views/front.py	Thu Jan 12 17:56:25 2012 +0100
@@ -61,7 +61,7 @@
 
 
 @login_required
-def annot_content(request, content_iri_id):
+def annot_content(request, content_iri_id, cutting_id=None):
     # Get the wanted content
     content = Content.objects.get(iri_id=content_iri_id)
     # The main project for the content
@@ -69,7 +69,7 @@
     # Vars for player
     player_id = "player_project_" + proj.ldt_id
     
-    json_url = reverse("ldt.ldt_utils.views.json.project_json_id", args=[proj.ldt_id])
+    json_url = reverse("ldt.ldt_utils.views.json.project_json_cutting_id", args=[proj.ldt_id, cutting_id])
     player_width = 550
     player_height = 380
     stream_mode = proj.stream_mode
--- a/src/ldt/ldt/ldt_utils/views/json.py	Thu Jan 12 16:25:13 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/views/json.py	Thu Jan 12 17:56:25 2012 +0100
@@ -29,7 +29,7 @@
 
 
 
-def project_json(request, project, serialize_contents=True, first_cutting=None): # Not checked
+def project_json(request, project, serialize_contents=True, first_cutting=None):
     
     if not ldt_auth.check_access(request.user, project):
         return HttpResponseForbidden(_("You can not access this project"))
@@ -58,7 +58,8 @@
         escape_bool = {'true': True, 'false': False, "0": False, "1": True}.get(escape_str.lower())
         
     viewable_contents = get_objects_for_user(request.user, 'ldt_utils.view_content', klass=project.contents.all())
-    viewable_contents = [c.iri_id for c in viewable_contents]    
+    viewable_contents = [c.iri_id for c in viewable_contents]
+        
     ps = ProjectSerializer(project, serialize_contents, viewable_contents=viewable_contents, first_cutting=first_cutting)
     project_dict = ps.serialize_to_cinelab()