v0.5.19 enhance import for content title V00.05.19
authorcavaliet
Tue, 27 May 2014 12:37:05 +0200
changeset 108 878a2c621fcf
parent 107 86fa41dd11fb
child 109 f23ad49cf588
v0.5.19 enhance import for content title
src/spel/__init__.py
src/spel/management/commands/loadoperadata.py
src/spel/templates/partial/spel_opera_annotations.html
--- a/src/spel/__init__.py	Tue May 27 11:07:49 2014 +0200
+++ b/src/spel/__init__.py	Tue May 27 12:37:05 2014 +0200
@@ -1,4 +1,4 @@
-VERSION = (0, 5, 18, "final", 0)
+VERSION = (0, 5, 19, "final", 0)
 
 VERSION_STR = unicode(".".join(map(lambda i:"%02d" % (i,), VERSION[:2])))
 
--- a/src/spel/management/commands/loadoperadata.py	Tue May 27 11:07:49 2014 +0200
+++ b/src/spel/management/commands/loadoperadata.py	Tue May 27 12:37:05 2014 +0200
@@ -23,6 +23,7 @@
 import time
 
 import logging
+from string import replace
 logger = logging.getLogger(__name__)
 
 
@@ -77,8 +78,10 @@
                 #print("Parsing walk %s, %s, %s" % (dirpath, dirnames, filenames))
                 for filename in filenames:
                     if filename == "cinelab_iri.json":
+                        ctt_id = os.path.basename(dirpath)
+                        # dirname is like "acte-1-stuff-thing_1234" and we want "Acte 1 stuff thing"
+                        content_title = ctt_id.split("_")[0].replace("-"," ").capitalize()
                         json_path = os.path.join(dirpath, filename)
-                        print("json_path %s" % json_path)
                         print("Parsing json file %s ..." % json_path)
                         json_data = False
                         try:
@@ -88,7 +91,6 @@
                         except:
                             print("Error while parsing json file.")
                         if json_data:
-                            ctt_id = os.path.basename(dirpath)
                             dur = int(json_data["medias"][0]["meta"]["duration"])
                             # Save media and content
                             media, _ = Media.objects.get_or_create(src="/data/opera/"+ctt_id+"/original_web.mp4", duration=dur)
@@ -96,7 +98,7 @@
                             content = Content.objects.create(iri_id=ctt_id, 
                                                              iriurl=ctt_id+u"/"+ctt_id+u".iri", 
                                                              media_obj=media, 
-                                                             title=json_data["meta"]["ucm:oeuvre"] + " " + json_data["meta"]["dc:created"][:10], 
+                                                             title=content_title, 
                                                              duration=dur,
                                                              content_creation_date = json_data["meta"]["dc:created"])
                             content.is_public = True
--- a/src/spel/templates/partial/spel_opera_annotations.html	Tue May 27 11:07:49 2014 +0200
+++ b/src/spel/templates/partial/spel_opera_annotations.html	Tue May 27 12:37:05 2014 +0200
@@ -40,8 +40,10 @@
         <td>{{ s.tags|get_tags:"opera_scene"|join:', ' }}</td>
         <td>{{ s.tags|get_tags:"opera_mesure"|join:', ' }}</td>
         <td>
-          <span class="glyphicon glyphicon-info-sign popinfo" data-trigger="hover" data-container="body" data-toggle="popover" data-placement="auto" 
-                  data-content="<strong>Timecodes:</strong> {{ s.start_ts|str_duration }} - {{ s.start_ts|add:s.duration|str_duration }}<br/><strong>Commentaire</strong>: {{ s.abstract }}"></span>
+          {% if s.abstract != "" %}<span class="glyphicon glyphicon-comment popinfo" data-trigger="hover" data-container="body" data-toggle="popover" data-placement="auto" 
+                  data-content="<strong>Commentaire</strong>: {{ s.abstract }}"></span>{% endif %}
+          <span class="glyphicon glyphicon-time popinfo" data-trigger="hover" data-container="body" data-toggle="popover" data-placement="auto" 
+                  data-content="<strong>Timecodes:</strong> {{ s.start_ts|str_duration }} - {{ s.start_ts|add:s.duration|str_duration }}"></span>
           <a class="play-button" href="{% url 'spel_player' %}?g={{ s.iri_id }}&d=opera&f=720p.mp4#id={{ s.element_id }}" target="_blank"><span class="glyphicon glyphicon-play"></span></a>
         </td>
     </tr>