Merge with 9f7680957db8f7501d7d48a304545c0920b45349
authorrougeronj
Fri, 30 Nov 2012 16:40:26 +0100
changeset 992 380d3657bc28
parent 991 232d40ae99d0 (current diff)
parent 990 9f7680957db8 (diff)
child 993 290c591457aa
Merge with 9f7680957db8f7501d7d48a304545c0920b45349
src/ldt/ldt/ldt_utils/views/content.py
--- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_content.html	Fri Nov 30 16:26:23 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_content.html	Fri Nov 30 16:40:26 2012 +0100
@@ -14,6 +14,11 @@
     <script type="text/javascript" src="{{LDT_MEDIA_PREFIX}}js/jquery.textchange.min.js"></script>
     <script type="text/javascript" src="{{LDT_MEDIA_PREFIX}}js/jquery-ui.min.js"></script>
     <script type="text/javascript" src="{{LDT_MEDIA_PREFIX}}js/swfupload/swfupload.js"></script>
+  
+  	<script type="text/javascript" src="{{ STATIC_URL }}chunked_uploads/js/jquery.ui.widget.js"></script>
+	<script type="text/javascript" src="{{ STATIC_URL }}chunked_uploads/js/jquery.iframe-transport.js"></script>
+	<script type="text/javascript" src="{{ STATIC_URL }}chunked_uploads/js/jquery.fileupload.js"></script>
+	<script type="text/javascript" src="{{ STATIC_URL }}chunked_uploads/js/progress.js"></script>
 	
 	{{ content_form.media.js }}
 {% endblock %}
@@ -59,6 +64,7 @@
 	<link rel="stylesheet" href="{{LDT_MEDIA_PREFIX}}css/blueprint/screen.css" type="text/css" media="screen, projection" />
 	<link rel="stylesheet" href="{{LDT_MEDIA_PREFIX}}css/blueprint/print.css" type="text/css" media="print" />
 	<link rel="stylesheet" href="{{LDT_MEDIA_PREFIX}}/css/workspace.css" type="text/css"/>
+	<link rel="stylesheet" href="{{ STATIC_URL }}chunked_uploads/css/chunked_upload.css" type="text/css"/>
 	
 	
 {% endblock %}
@@ -108,14 +114,17 @@
 		<div>{{ content_form.media_input_type.errors }}{{ content_form.media_input_type.label_tag }}{{content_form.media_input_type}}</div>
 		<div id="media_fields_div">
 			<div id="media_field_link" class="media_fields">{{ content_form.media_obj.errors }}{{ content_form.media_obj.label_tag }}{{content_form.media_obj}}</div>
+			
 			<div id="media_field_upload" class="media_fields">
-				{{ media_form.media_file.errors }}
-				{% comment %}{{ media_form.media_file.label_tag }}{{media_form.media_file}}{% endcomment %}
-				<div id="upload_btn"></div>
-				<input type="text" name="media-local_file_name" id="id_media-local_file_name" readonly/>
-				<div id="upload_progress_bar"></div>
-				<div id="upload_progress_info"></div>
+				<input type="file" id="fileupload" name="files[]" accept="video/* wmv"/>
+				<button class="Start"><span>{% trans 'Start' %}</span></button>
+				<button class="Stop"><span>{% trans 'Stop' %}</span></button>
+				<button class="cancel"><span>{% trans 'Cancel' %}</span></button>
+				<div class="bar grey stripes">
+  					<span class="progress" style="width: 0%"></span>
+				</div>
 			</div>
+			
 			<div id="media_field_url" class="media_fields">{{ media_form.external_src_url.errors }}{{ media_form.external_src_url.label_tag }}{{ media_form.external_src_url }}</div>
 			<div id="media_field_create" class="media_fields">{{ media_form.src.errors }}{{ media_form.src.label_tag }}{{ media_form.src }}</div>
 		</div>
@@ -132,7 +141,6 @@
 		{% endif %}
 	{% include "ldt/ldt_utils/partial/picture.html"%}
 	{% include "ldt/ldt_utils/partial/permissions.html" %}
-
 		
 	<div id="submitcontent" class="span-18 last">
 		<div id="submitcontent-loader" class="span-10">
--- a/src/ldt/ldt/ldt_utils/tests/content_tests.py	Fri Nov 30 16:26:23 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/tests/content_tests.py	Fri Nov 30 16:40:26 2012 +0100
@@ -16,6 +16,8 @@
 import unittest
 import uuid
 import logging
+import os
+import exceptions
 
 class ContentTest(TestCase):
     
@@ -29,7 +31,7 @@
         
         self.user = User()
         self.user.username = 'blop'
-
+        
     #test the creation of a content without media
     def test_create_content_v1(self):
         self.cont12 = Content(iriurl="id12/iriurl12", duration = 100)
@@ -46,8 +48,54 @@
         self.cont13.iri_id = "id113"
         self.cont13.save()
         
-        self.assertEqual(Content.objects.get(iri_id=self.cont13.iri_id), self.cont13) 
-    
+        self.assertEqual(Content.objects.get(iri_id=self.cont13.iri_id), self.cont13)
+
+    #test the creation of content without reading permission
+    def test_create_content_v3(self):
+        import sys
+        ldt_dir = os.path.join(settings.MEDIA_ROOT, "ldt")
+        if sys.platform == 'win32':
+            logging.debug("windows 3")
+        else:
+            logging.debug("linux")
+            os.chmod(ldt_dir, 0577)
+            
+            self.cont17 = Content(iriurl="id17/iriurl17", duration = 100)
+            self.cont17.iri_id = 'id117'
+            with self.assertRaises(WindowsError):
+                self.cont17.save()
+            with self.assertRaises(Content.DoesNotExist):
+                Content.objects.get(iri_id=self.cont17.iri_id)
+            
+        if sys.platform == 'win32':
+            logging.debug("windows 4")
+        else:
+            logging.debug("linux")
+            os.chmod(ldt_dir, 0700)
+            
+        #test the creation of content without reading permission
+    def test_create_content_v4(self):
+        import sys
+        ldt_dir = os.path.join(settings.MEDIA_ROOT, "ldt")
+        if sys.platform == 'win32':
+            logging.debug("windows 3")
+        else:
+            logging.debug("linux")
+            os.chmod(ldt_dir, 0377)
+            
+            self.cont18 = Content(iriurl="id18/iriurl18", duration = 100)
+            self.cont18.iri_id = 'id118'
+            with self.assertRaises(WindowsError):
+                self.cont18.save()    
+            with self.assertRaises(Content.DoesNotExist):
+                Content.objects.get(iri_id=self.cont18.iri_id)
+            
+        if sys.platform == 'win32':
+            logging.debug("windows 4")
+        else:
+            logging.debug("linux")
+            os.chmod(ldt_dir, 0700)  
+         
     #test the deletion of a content without media
     def test_del_content_v1(self):
         self.cont14 = Content(iriurl="id14/iriurl14", duration = 100)
--- a/src/ldt/ldt/ldt_utils/tests/ldt_tests.py	Fri Nov 30 16:26:23 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/tests/ldt_tests.py	Fri Nov 30 16:40:26 2012 +0100
@@ -68,7 +68,6 @@
         self.assertEqual(ldoc.xpath("/iri/medias/media")[1].get("id"), self.cont2.iri_id)
         f.close()
         
-    """
     def test_generate_init(self):
         self.cont3 = Content(iriurl="id3/iriurl3", duration=111)
         self.cont3.iri_id = "id3"
@@ -82,7 +81,6 @@
         ldoc = self.LU.generate_init([], 'ldt.ldt_utils.views.search_ldt')
         self.assertEqual(ldoc.xpath("/iri/files/init")[0].tag, "init")
         self.assertEqual(ldoc.xpath("/iri/files/library")[0].tag, "library")
-    """
     
     def test_create_ldt(self):
         self.cont5 = Content(iriurl="id5/iriurl5", duration=111)
--- a/src/ldt/ldt/ldt_utils/tests/project_tests.py	Fri Nov 30 16:26:23 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/tests/project_tests.py	Fri Nov 30 16:40:26 2012 +0100
@@ -52,4 +52,26 @@
 
         with self.assertRaises(Project.DoesNotExist):
             Project.objects.get(ldt_id=self.project3.ldt_id)
-        
\ No newline at end of file
+    
+    #test deletion of project with annotations  
+    def test_del_project_v2(self):
+        
+        self.project4 = Project(title="titleproj3", owner=self.user)
+        self.project4.ldt = '<iri ldtversion="1.0.3" xmlns:dc="http://dublincore.org/documents/dcmi-namespace/"><project id="af3b99e4-b695-11df-bfde-00145ea4a333" user="admin" title="CA:reponse a TC" abstract=""/> <medias> <media extra="" id="laurentcantet_entrelesmurs" pict="" src="http://amateur.iri.centrepompidou.fr//atelier/static/media/ldt/laurentcantet_entrelesmurs/laurentcantet_entrelesmurs.iri" video="rtmp://media.iri.centrepompidou.fr/ddc_player/video/regardssignes/"/> </medias> <annotations> <content id="laurentcantet_entrelesmurs"> <ensemble id="ens_perso" idProject="fe0d5d4c-2201-11df-8a24-00145ea4a2be" title="Decoupages personnels" author="perso" abstract=""> <decoupage id="c_EFC3FFE7-0204-A086-EBEC-D2A03A0E56CB" author="perso"> <title>CA: prof et admin</title> <abstract/> <elements> <element id="s_442AAB3A-42DA-F9BF-75E7-D2A0663FD5FF" begin="985690" dur="373222" author="" date="2010/09/02" color="16711680" src=""> <title/> <abstract/> <audio source=""/> <tags/> </element> <element id="s_0050F043-3AD2-0A7C-6699-D2A03A1EBA02" begin="5052858" dur="124407" author="" date="2010/09/02" color="10053375" src=""> <title>conseil de classe</title> <abstract>Reprise de la figure precedente</abstract> <audio source="undefined"/> <tags/> </element> </elements> </decoupage> <decoupage id="c_EEEF5C29-86E1-4AAE-E068-04EB5B00E492" author="perso"> <title>TC: prof et admin</title> <abstract/> <elements> <element id="s_880D9D4B-8BC0-BA43-5ECA-04EBA9FC9E59" begin="2426894" dur="141478" author="" date="2010/02/25" color="10053375" src=""> <title>Conseil de classe</title> <abstract/> <audio source=""/> <tags> <tag>Argumentation</tag> </tags> </element> <element id="s_D568A57C-7110-DED2-3165-04EC54387060" begin="5052858" dur="124407" author="" date="2010/02/25" color="10053375" src=""> <title>conseil de classe</title> <abstract>Reprise de la figure precedente</abstract> <audio source="undefined"/> <tags/> </element> </elements> </decoupage> </ensemble> </content> </annotations> <displays> <display id="0" title="Init view" idsel="laurentcantet_entrelesmurs" tc="2426424" zoom="0" scroll="0" infoBAB=""> <audio source=""/> <content id="laurentcantet_entrelesmurs"> <decoupage idens="en_2" id="de_PPP" tagsSelect=""/> <decoupage idens="laurentcantet_entrelesmurs" id="c_14A2E638-1936-97DC-E303-2DBA6A82A8B3" tagsSelect=""/> <decoupage idens="ens_perso" id="c_EEEF5C29-86E1-4AAE-E068-04EB5B00E492" tagsSelect=""/> <decoupage idens="ens_perso" id="c_EFC3FFE7-0204-A086-EBEC-D2A03A0E56CB" tagsSelect=""/> </content> </display> </displays> <edits> <editing id="0" tags=""> <title>Bout a bout 1</title> <abstract/> <edit id="edit1" tags=""> <eList/> <caption/> <audio/> <mList/> </edit> <edit id="edit2" tags=""> <eList/> <caption/> <audio/> <mList/> </edit> </editing> </edits> </iri>'
+        self.project4.id = "444"
+        self.project4.ldt_id = str(uuid.uuid1())
+        self.project4.description = "proj4description"
+        self.project4.save()
+        
+        create_ldt(self.project4, self.user)
+        
+        self.LA = LdtAnnotation(self.project4)
+
+        self.LA.add("id11", "cutting_id", "cutting_title", "title", "text", ["tag1", "tag2"], "800",
+                    "10000", "jdoe", "2011-09-10T09:12:58")
+        self.LA.save()
+        
+        self.project4.delete()
+
+        with self.assertRaises(Project.DoesNotExist):
+            Project.objects.get(ldt_id=self.project4.ldt_id)
\ No newline at end of file
--- a/src/ldt/ldt/static/ldt/js/projectscontents.js	Fri Nov 30 16:26:23 2012 +0100
+++ b/src/ldt/ldt/static/ldt/js/projectscontents.js	Fri Nov 30 16:40:26 2012 +0100
@@ -460,81 +460,6 @@
     $("#upload_progress_bar").css({ width:"90%", height:"10" });
     
     $('#media_fields_div').height(80);
-    
-    // We init the swfupload object
-    swfupload = new SWFUpload({
-        debug: false,
-        
-        upload_url: url_upload,
-        flash_url: media_prefix+"swf/swfupload.swf",
-        
-        post_params: post_added_params,
-        
-        button_placeholder_id: "upload_btn",
-        button_width: "60",
-        button_height: "16",
-        button_cursor: SWFUpload.CURSOR.HAND,
-        button_text : '<span class="btnText">' + btn_label + '</span>',
-        button_text_style : ".btnText { font-size: 12; font-family: Arial; }",
-        
-        file_types : "*.flv;*.f4v;*.mp4;*.mov;*.mp3",
-        file_types_description : "Media Files (flv, f4v, mov H264, mp4, mp3)",
-        file_upload_limit : "1",
-        file_queue_limit : "1",
-        
-        upload_error_handler : uploadError,
-        upload_start_handler : function(file) {
-            try {
-                if($('#upload_progress_info').children().size()>0){
-                    $('#progress_info').remove();
-                }
-                $('#upload_progress_info').append('<p id="progress_info"><a href="javascript:cancelSwfUpload()">' + cancel_label + '.</a></p>');
-            }
-            catch (ex) {
-                //this.debug(ex);
-            }
-        },
-        upload_progress_handler : uploadProgress,
-        upload_success_handler : function() {
-                try {
-                    if($('#upload_progress_info').children().size()>0){
-                        $('#progress_info').remove();
-                    }
-                    $('#upload_progress_info').append('<p id="progress_info">' + success_label + '.</p>');
-                    $("#upload_progress_bar > div").css({ 'background': '#90ffa8' });
-                    window.upload_from_local_done = true;
-                    // Now that the file is uploaded, we submit the form if asked
-                    if(window.submit_asked==true){
-                        $('#my_form').submit();
-                    }
-                    else{
-                        // We ask the uploaded media's duration
-                        if(window.ask_duration_url){
-                            $.ajax({
-                                type: "GET",
-                                url: window.ask_duration_url,
-                                data: "filename="+ $('#id_media-local_file_name').val(),
-                                cache: false,
-                                success: function(data, status, request){
-                                    if(data && data!=""){
-                                        $('#id_content-duration').val(data);
-                                    }
-                                }
-                            });
-                        }
-                    }
-                }
-                catch (ex) {
-                    //this.debug(ex);
-                }
-            },
-        file_queued_handler : displayUploadPath,
-        file_dialog_complete_handler: function() { 
-            window.submit_asked = false;
-            this.startUpload();
-        }
-        //upload_complete_handler: function() { this.startUpload(); },
-    });
 }
 function displayUploadPath(file) {
     try {
@@ -544,62 +469,6 @@
         //this.debug(ex);
     }
 }
-function startLocalUpload(){
-    swfupload.startUpload();
-}
-function uploadProgress(file, bytesLoaded, bytesTotal) {
-    try {
-        var percent = Math.ceil((bytesLoaded / bytesTotal) * 100);
-        $("#upload_progress_bar").progressbar({ value: percent });
-    }
-    catch (ex) {
-        //this.debug(ex);
-    }
-}
-function cancelSwfUpload(){
-    swfupload.cancelUpload();
-    if($('#media_field_upload').has($('#cancelupload')).length==0){
-        $('#cancelupload').remove();
-    }
-}
-function uploadError(file, errorCode, message) {
-    try {
-        if($('#upload_progress_info').children().size()>0){
-            $('#progress_info').remove();
-        }
-        switch (errorCode) {
-        case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
-            $('#upload_progress_info').append('<p id="progress_info">' + "Error Code: HTTP Error, File name: " + file.name + ", Message: " + message + '</p>');
-            break;
-        case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
-            $('#upload_progress_info').append('<p id="progress_info">' + "Error Code: Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message + '</p>');
-            break;
-        case SWFUpload.UPLOAD_ERROR.IO_ERROR:
-            $('#upload_progress_info').append('<p id="progress_info">' + "Error Code: IO Error, File name: " + file.name + ", Message: " + message + '</p>');
-            break;
-        case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
-            $('#upload_progress_info').append('<p id="progress_info">' + "Error Code: Security Error, File name: " + file.name + ", Message: " + message + '</p>');
-            break;
-        case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
-            $('#upload_progress_info').append('<p id="progress_info">' + "Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message + '</p>');
-            break;
-        case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
-            $('#upload_progress_info').append('<p id="progress_info">' + "Error Code: File Validation Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message + '</p>');
-            break;
-        case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
-            $('#upload_progress_info').append('<p id="progress_info">' + "Error Code: FILE_CANCELLED" + '</p>');
-            break;
-        case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
-            $('#upload_progress_info').append('<p id="progress_info">' + "STOPPED" + '</p>');
-            break;
-        default:
-            $('#upload_progress_info').append('<p id="progress_info">' + "unhandled error: File name: " + file.name + ", File size: " + file.size + ", Message: " + message + '</p>');
-            break;
-        }
-    } catch (ex) {
-        //this.debug(ex);
-    }
-}
 
 // Test the value of the URL from the form to load a picture in case it is a youtube video
 function testUrlValue(e){