Merge with dfdd945df4aee0ef14c6ae458a1909f7a9c0bd16
authorcavaliet
Thu, 07 Jun 2012 18:18:05 +0200
changeset 655 acafed2ba960
parent 654 69b3c4d7a7c1 (diff)
parent 653 dfdd945df4ae (current diff)
child 657 e161a1664cac
Merge with dfdd945df4aee0ef14c6ae458a1909f7a9c0bd16
src/ldt/ldt/user/migrations/0008_auto__chg_field_groupprofile_image__chg_field_groupprofile_group__chg_.py
virtualenv/res/src/django-extensions-0.6.tar.gz
virtualenv/res/src/django-piston-0.2.2-modified.tar.gz
virtualenv/res/src/django-registration.tar.gz
virtualenv/res/src/fabric-1.4.1.tar.gz
virtualenv/res/src/httplib2-0.6.0.tar.gz
virtualenv/res/src/lxml-2.3.1.tar.bz2
virtualenv/res/src/mercurial-2.2.1.tar.gz
virtualenv/res/src/oauth2-1.5.167.tar.gz
virtualenv/res/src/psycopg2-2.4.tar.gz
virtualenv/res/src/pylucene-3.1.0-1-src.tar.gz
virtualenv/res/src/south-0.7.3.tar.gz
virtualenv/res/src/ssh-1.7.13.tar.gz
virtualenv/res/src/zlib-1.2.6.tar.gz
--- a/src/ldt/ldt/api/ldt/handlers.py	Thu Jun 07 11:43:48 2012 +0200
+++ b/src/ldt/ldt/api/ldt/handlers.py	Thu Jun 07 18:18:05 2012 +0200
@@ -90,6 +90,11 @@
                             "end": 2100000,\
                             "content": {\
                                 "data": "new scar annot"\
+                                "audio": {\
+                                    "mimetype": "audio/mp3",\
+                                    "src": "mic",\
+                                    "href": "rtmp://media.iri.centrepompidou.fr/ddc_micro_record/r_20120606190143793"\
+                                }\
                             },\
                             "tags": [ "json","dude" ]\
                         }\
@@ -194,7 +199,15 @@
         for a in new_annotations:
             dur = str(a['end'] - a['begin'])
             begin = str(a['begin'])
-            type_id, new_id = adder.add(a['media'], a['type'], a['type_title'], a['content']['data'], '', a['tags'], begin, dur, author, date)
+            # We test if the annotation has audio node
+            audio_src = ""
+            audio_href = ""
+            if a['content'].has_key('audio') :
+                if a['content']['audio'].has_key('src') :
+                    audio_src = a['content']['audio']['src']
+                if a['content']['audio'].has_key('href') :
+                    audio_href = a['content']['audio']['href']
+            type_id, new_id = adder.add(a['media'], a['type'], a['type_title'], a['content']['data'], '', a['tags'], begin, dur, author, date, None, "2194379", audio_src, audio_href)
             if not new_id:
                 protect_models()
                 return rc.BAD_REQUEST
@@ -206,6 +219,8 @@
             # We update the ids
             a['type'] = type_id
             a['id'] = new_id
+            if not a['content'].has_key('audio') :
+                a['content']['audio'] = {'src':audio_src, 'href':audio_href}
         
         # We save if there were added annotation
         if len(new_annotations)>0 :
--- a/src/ldt/ldt/ldt_utils/utils.py	Thu Jun 07 11:43:48 2012 +0200
+++ b/src/ldt/ldt/ldt_utils/utils.py	Thu Jun 07 18:18:05 2012 +0200
@@ -171,7 +171,7 @@
         self.to_add = True
         
     #   add( a['media'], a['type'],  a['type_title, a[data], '', a['tags'], begin, dur, author, date)
-    def add(self, media, cutting_id, cutting_title, title, text, tags_list, begin, dur, author, date, view_id="0", color="2194379"):
+    def add(self, media, cutting_id, cutting_title, title, text, tags_list, begin, dur, author, date, view_id="0", color="2194379", audio_scr="", audio_href=""):
         """
         Add an annotation to a project. begin and dur must be strings. Default color is yellow.
         """
@@ -262,7 +262,8 @@
         title_node = lxml.etree.SubElement(element, 'title')
         title_node.text = title
         audio = lxml.etree.SubElement(element, 'audio')
-        audio.set('source', '')
+        audio.set('source', audio_scr)
+        audio.text = audio_href
         tags = lxml.etree.SubElement(element, 'tags')
                                 
         polemics = self.get_polemic_syntax(title)