--- a/src/ldt/ldt/api/ldt/resources/segment.py Wed Feb 27 00:07:54 2013 +0100
+++ b/src/ldt/ldt/api/ldt/resources/segment.py Wed Feb 27 00:12:24 2013 +0100
@@ -2,11 +2,11 @@
from django.conf.urls.defaults import url
from django.core.paginator import Paginator, InvalidPage
from django.db.models import F, Q
-from ldt.indexation import get_results_with_context
+from ldt.indexation import get_results_list
from ldt.ldt_utils.models import Content, Segment
from ldt.ldt_utils.segmentserializer import SegmentSerializer
from tastypie.constants import ALL
-from tastypie.http import HttpNotFound
+from tastypie.exceptions import BadRequest, NotFound
from tastypie.resources import ModelResource
from tastypie.utils import trailing_slash
import logging
@@ -40,8 +40,9 @@
self.method_check(request, allowed=['get'])
# Do the query.
search = request.GET.get('q', '')
+ if search=='':
+ raise BadRequest('The request needs a search query "q=" parameter.')
field = "all"
- content_list = None
if u'author:' in search.lower() :
sub = search[7:]
sub = sub.upper()
@@ -50,22 +51,25 @@
if sub[-1] != u'"':
sub = sub + u'"'
search = u'author:' + sub
- results = get_results_with_context(field, search, content_list)
- all_segments = Segment.objects.filter(element_id__in=[e['element_id'] for e in results])
- paginator = Paginator(all_segments, getattr(settings, 'API_LIMIT_PER_PAGE', 20))
-
+
+ results = get_results_list(field, search, False)
+ # get_results_list returns a SearchQuerySet, we load_all() to get all real Segment objects
+ all_segments = results.load_all()
+ paginator = Paginator(all_segments, request.GET.get("limit") or getattr(settings, 'API_LIMIT_PER_PAGE', 20))
+
try:
page = paginator.page(int(request.GET.get('page', 1)))
except InvalidPage:
- raise HttpNotFound("Sorry, no results on that page.")
-
+ raise NotFound("Sorry, no results on that page.")
+
objects = []
-
- for segment in page.object_list:
- bundle = self.build_bundle(obj=segment, request=request)
+
+ for search_res in page.object_list:
+ # search_res is a SearchResult, search_res.object is the real Segment Object thanks to results.load_all()
+ bundle = self.build_bundle(obj=search_res.object, request=request)
bundle = self.full_dehydrate(bundle)
objects.append(bundle)
-
+
object_list = {
'objects': objects,
}
@@ -80,15 +84,15 @@
returns segments about content iri_id between timecodes begin and end
"""
if not begin:
- return HttpNotFound("begin timecode argument is missing.")
+ raise NotFound("begin timecode argument is missing.")
if not end:
- return HttpNotFound("end timecode argument is missing.")
+ raise NotFound("end timecode argument is missing.")
begin = int(begin)
end = int(end)
content = Content.objects.filter(iri_id=iri_id).select_related('media_obj', 'stat_annotation')
if not content:
- return HttpNotFound("Content does not exist or id is not correct.")
+ raise NotFound("Content does not exist or id is not correct.")
content = content[0]
segments = Segment.objects.filter(content=content).filter(
--- a/src/ldt/ldt/ldt_utils/templates/front/front_home.html Wed Feb 27 00:07:54 2013 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_home.html Wed Feb 27 00:12:24 2013 +0100
@@ -112,7 +112,7 @@
<a href="{% url ldt.ldt_utils.views.front.group_info group.id %}">{% thumbnail group.get_profile.image "54x40" format="PNG" crop="center" as im %}<img src="{{ im.url }}" class="img_media" width="{{ im.width }}" height="{{ im.height }}" alt="{% trans 'group picture' %}" title="{% trans 'view more infos on this group'%}">{% endthumbnail %}</a>
</div>
<div class="txt_groupes_actifs">
- <div class="bulle_people" title="{% blocktrans count nb=group.user_set.count %}{{nb}} user in this group{% plural %}{{nb}} users in this group{% endblocktrans %}">{{ group.user_set.count }}</div>
+ <div class="bulle_people" title="{% blocktrans count nb=group.nb_users %}{{nb}} user in this group{% plural %}{{nb}} users in this group{% endblocktrans %}">{{ group.nb_users }}</div>
<p><a href="{% url ldt.ldt_utils.views.front.group_info group.id %}" class="under" title="{% trans 'view more infos on this group'%}"><b>{{group.name}}</b></a></p>
<p>{% if group.get_profile.description|striptags|length > 69 %}{{group.get_profile.description|striptags|slice:":69"}}...{% else %}{{group.get_profile.description|striptags}}{% endif %}</p>
</div>
--- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_content.html Wed Feb 27 00:07:54 2013 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_content.html Wed Feb 27 00:12:24 2013 +0100
@@ -10,12 +10,12 @@
{{ block.super }}
<script type="text/javascript" src="{{ADMIN_MEDIA_PREFIX}}js/core.js" ></script>
<script type="text/javascript" src="{{ADMIN_MEDIA_PREFIX}}js/jquery.init.js"></script>
- <script type="text/javascript" src="{{ADMIN_MEDIA_PREFIX}}js/jquery.min.js"></script>
+ <script type="text/javascript" src='{% absstatic "ldt/js/jquery.min.js" %}'></script>
+ <script type="text/javascript" src="{% url ldt.jsi18n packages='ldt' %}" ></script>
<script type="text/javascript" src="{% absurl ldt.jsi18n packages='ldt' %}" ></script>
<script type="text/javascript" src='{% absstatic "ldt/js/projectscontents.js" %}'></script>
<script type="text/javascript" src='{% absstatic "ldt/js/jquery.textchange.min.js" %}'></script>
<script type="text/javascript" src='{% absstatic "ldt/js/jquery-ui.min.js" %}'></script>
- <script type="text/javascript" src='{% absstatic "ldt/js/swfupload/swfupload.js" %}'></script>
{{ content_form.media.js }}
{% endblock %}
@@ -29,26 +29,50 @@
post_added_params = {"csrfmiddlewaretoken" : "{{csrf_token}}",
"{{cookie_name}}" : "{{session_key}}"};
- onCreateContentReady("{% url ldt.ldt_utils.views.content.upload %}",
- '{% absstatic "ldt" %}',
- post_added_params,
- '{% trans "Browse" %}',
- '{% trans "File uploaded" %}',
- '{% trans "Please wait, the upload is not finished yet" %}',
- '{% trans "Cancel upload" %}',
- "{% url ldt.ldt_utils.views.content.remove_temp_file %}",
- "{% url ldt.ldt_utils.views.content.get_duration %}");
-
+ onCreateContentReady('{% absstatic "ldt" %}', post_added_params);
});
// the function stopRKey prevents from the validation of the form if the user tape enter button while entering a field
function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
- }
+ }
document.onkeypress = stopRKey;
+ chunked_uploads_endpoints = {
+ upload_url: '{{WEB_URL}}{% url upload %}',
+ done_url: '{{WEB_URL}}{% url upload_done uuid='00000000-0000-0000-0000-000000000000' %}',
+ };
+
+ $(function() {
+ //gets video_url and returns it to the "scr" field
+ chunked_uploads_video_url = function(video_url) {
+ $('#id_content-media_input_type').val("create");
+ $('#id_media-src').val(video_url);
+ $('#id_media-src').attr('readOnly', true);
+ $(".media_fields").hide();
+ $("#media_field_create").show();
+ $('#upload_url').append(video_url);
+ };
+
+ //callback of chunked upload start
+ chunked_uploads_start = function(){
+ };
+
+ //callback of chunked upload stop
+ chunked_uploads_stop = function(){
+ };
+
+ //callback of chunked upload error
+ chunked_uploads_error = function(){
+ alert("The upload failed. Please reload the page, and try again.");
+ };
+
+ //callback of chunked upload complete
+ chunked_uploads_complete = function(){
+ };
+ });
</script>
{% endblock %}
@@ -60,7 +84,7 @@
<link rel="stylesheet" href='{% absstatic "ldt/css/style.css" %}'/>
<link rel="stylesheet" href='{% absstatic "ldt/css/blueprint/screen.css" %}' type="text/css" media="screen, projection" />
<link rel="stylesheet" href='{% absstatic "ldt/css/blueprint/print.css" %}' type="text/css" media="print" />
- <link rel="stylesheet" href='{% absstatic "ldt//css/workspace.css" %}'type="text/css"/>
+ <link rel="stylesheet" href='{% absstatic "ldt/css/workspace.css" %}'type="text/css"/>
{% endblock %}
@@ -114,15 +138,14 @@
<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>
+ <!-- refers to chunked_upload template -->
+ {% include "chunked_uploads.html"%}
</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>
</div>
@@ -138,7 +161,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">
@@ -155,4 +177,8 @@
</form>
</div>
+ <script type="text/javascript" src='{% absstatic "chunked_uploads/js/jquery.ui.widget.js" %}'></script>
+ <script type="text/javascript" src='{% absstatic "chunked_uploads/js/jquery.iframe-transport.js" %}'></script>
+ <script type="text/javascript" src='{% absstatic "chunked_uploads/js/jquery.fileupload.js" %}'></script>
+ <script type="text/javascript" src='{% absstatic "chunked_uploads/js/jquery.chunked_uploads.js" %}'></script>
{% endblock %}
--- a/src/ldt/ldt/ldt_utils/urls.py Wed Feb 27 00:07:54 2013 +0100
+++ b/src/ldt/ldt/ldt_utils/urls.py Wed Feb 27 00:12:24 2013 +0100
@@ -1,4 +1,4 @@
-from django.conf.urls.defaults import patterns, url
+from django.conf.urls.defaults import patterns, url, include
from ldt.management import test_ldt
# Uncomment the next two lines to enable the admin:
@@ -75,5 +75,5 @@
url(r'^space/upload/$', 'views.content.upload'),
url(r'^space/removetempfile/$', 'views.content.remove_temp_file'),
url(r'^space/getduration/$', 'views.content.get_duration'),
-
+ url(r'^chunked_uploads/', include('chunked_uploads.urls')),
)
--- a/src/ldt/ldt/ldt_utils/views/content.py Wed Feb 27 00:07:54 2013 +0100
+++ b/src/ldt/ldt/ldt_utils/views/content.py Wed Feb 27 00:12:24 2013 +0100
@@ -105,7 +105,6 @@
except Exception as inst:
- logging.debug("write_content_base : POST error when processing file:" + str(inst)) #@UndefinedVariable
form_status = "error"
#set error for form
if media_input_type == "url":
@@ -153,9 +152,8 @@
@transaction.commit_manually
def write_content_base(request, iri_id=None):
if iri_id:
- instance_content = Content.safe_objects.get(iri_id=iri_id) #@UndefinedVariable
+ instance_content = Content.safe_objects.select_related('media_obj','front_project').get(iri_id=iri_id) #@UndefinedVariable
instance_media = instance_content.media_obj
- logging.debug("write_content_base : valid form: for instance : media -> " + repr(instance_media) + " content : for instance : " + repr(instance_content)) #@UndefinedVariable
else:
logging.debug("No iri_id") #@UndefinedVariable
instance_content = None
@@ -216,7 +214,6 @@
picture_form.cleaned_data["image"]=File(img_temp)
except Exception as inst:
logging.debug("couldn't download video thumbnail from image_link : " + str(image_link))
- logging.debug("write_content_base : valid form: for instance : " + repr(instance_media) + " -> media " + str(media_valid) + " content : for instance : " + repr(instance_content) + " : " + str(content_valid) + "picture : valid :" +str(picture_valid)) #@UndefinedVariable
if media_valid and content_valid and picture_valid:
@@ -279,7 +276,7 @@
except Exception, e:
transaction.rollback()
__, value, traceback = sys.exc_info()
- return False, False, False, False, False, e, traceback
+ return False, False, False, False, False, False, e, traceback
else:
form_status = 'empty'
@@ -308,9 +305,9 @@
except Exception, e:
transaction.rollback()
__, __, traceback = sys.exc_info()
- return False, False, False, False, False, e, traceback
+ return False, False, False, False, False, False, e, traceback
- return content_form, media_form, picture_form, form_status, current_front_project, "", ""
+ return content_form, media_form, picture_form, form_status, instance_content, current_front_project, "", ""
@login_required
def write_content(request, iri_id=None):
@@ -352,7 +349,7 @@
return render_to_response('ldt/ldt_utils/reset_confirm.html', {'errors':errors, 'message':message, 'title': title}, context_instance=RequestContext(request))
elif submit_action == "reset":
#TODO : verifier index de la recherche maj
- content = Content.objects.get(iri_id=iri_id)
+ content = Content.objects.get(iri_id=iri_id).select_related('front_project')
project_temp = content.front_project
content.create_front_project()
content.save()
@@ -361,9 +358,9 @@
elif submit_action=="close":
return redirect("root-view")
else:
- content_form, media_form, picture_form, form_status, current_front_project, e, traceback = write_content_base(request, iri_id)
+ content_form, media_form, picture_form, form_status, content_temp, current_front_project, e, traceback = write_content_base(request, iri_id)
if iri_id:
- content_temp = Content.objects.get(iri_id=iri_id)
+ #content_temp = Content.objects.select_related('media_obj').get(iri_id=iri_id)
media_temp = content_temp.media_obj
if media_temp:
member_list, admin_list = get_userlist_model(media_temp, request.user)
--- a/src/ldt/ldt/ldt_utils/views/front.py Wed Feb 27 00:07:54 2013 +0100
+++ b/src/ldt/ldt/ldt_utils/views/front.py Wed Feb 27 00:12:24 2013 +0100
@@ -2,6 +2,7 @@
from django.contrib.auth.models import Group, User
from django.core.paginator import Paginator, InvalidPage, EmptyPage
from django.core.urlresolvers import reverse
+from django.db.models import Count
from django.shortcuts import render_to_response
from django.template import RequestContext
from guardian.shortcuts import get_objects_for_group
@@ -13,23 +14,24 @@
from ldt.utils.url import absstatic
import base64
+import logging
+logger = logging.getLogger(__name__)
def front_home(request):
# Get the 3 last annotated contents
- last_contents = Content.safe_objects.order_by('-stat_annotation__last_annotated').exclude(stat_annotation__nb_annotations=0)[:3]
+ last_contents = Content.safe_objects.order_by('-stat_annotation__last_annotated').select_related('stat_annotation').exclude(stat_annotation__nb_annotations=0)[:3]
# Get the most annotated contents
- most_contents = Content.safe_objects.order_by('-stat_annotation__nb_annotations')[:8]
+ most_contents = Content.safe_objects.order_by('-stat_annotation__nb_annotations').select_related('stat_annotation')[:8]
# Get the active groups
- active_groups = Group.objects.exclude(name=settings.PUBLIC_GROUP_NAME)[:5]
+ active_groups = Group.objects.select_related("profile").annotate(nb_users=Count("user")).exclude(name=settings.PUBLIC_GROUP_NAME)[:5]
# Get the main tag list
front_tags = settings.FRONT_TAG_LIST
# Get the all tags list
tag_cloud = get_content_tags()
-
is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1);
-
+
return render_to_response("front/front_home.html",
{'last_contents': last_contents, 'most_contents':most_contents, 'active_groups':active_groups, 'front_tags':front_tags,
'tag_cloud': tag_cloud, 'is_gecko': is_gecko},
@@ -65,11 +67,11 @@
tag_label = request.GET.get("tag")
# Get all the public contents group
if tag_label is None :
- content_list = Content.safe_objects.all()
+ content_list = Content.safe_objects.all().select_related('stat_annotation')
else :
- content_list = TaggedItem.objects.get_by_model(Content.safe_objects.all(), '"'+tag_label+'"')
+ content_list = TaggedItem.objects.get_by_model(Content.safe_objects.all().select_related('stat_annotation'), '"'+tag_label+'"')
else :
- content_list = Content.safe_objects.filter(title__icontains=media_title)
+ content_list = Content.safe_objects.filter(title__icontains=media_title).select_related('stat_annotation')
nb = settings.LDT_FRONT_MEDIA_PER_PAGE
@@ -158,7 +160,6 @@
content_list = TaggedItem.objects.get_by_model(Content.objects.all(), '"'+content_tag+'"')
results, nb, nb_segment = get_search_results(request, search, field, page, content_list)
-
return render_to_response('front/front_search_results.html', {'results': results, 'nb_results' : nb, 'nb_segment':nb_segment, 'search' : search, 'field': field, 'tag_label':content_tag, 'colorurl': colorurl, 'i18nurl': i18nurl, 'language': language_code, 'baseurl': baseurl}, context_instance=RequestContext(request))
--- a/src/ldt/ldt/ldt_utils/views/workspace.py Wed Feb 27 00:07:54 2013 +0100
+++ b/src/ldt/ldt/ldt_utils/views/workspace.py Wed Feb 27 00:12:24 2013 +0100
@@ -320,7 +320,7 @@
results = get_results_with_context(field, search, content_list)
all_segments = Segment.objects.filter(element_id__in=[e['element_id'] for e in results])
all_projects = Project.objects.filter(ldt_id__in=[e['project_id'] for e in results], state=2)
- all_contents = Content.objects.filter(iri_id__in=[e['iri_id'] for e in results])
+ all_contents = Content.objects.filter(iri_id__in=[e['iri_id'] for e in results]).select_related('stat_annotation')
viewable_projects_id = [p.ldt_id for p in all_projects]
nb_segment=0
complete_results = []
--- a/src/ldt/ldt/management/commands/reindex.py Wed Feb 27 00:07:54 2013 +0100
+++ b/src/ldt/ldt/management/commands/reindex.py Wed Feb 27 00:12:24 2013 +0100
@@ -16,11 +16,17 @@
action="store",
type="string",
help="Index only the content specified by CONTENT_ID."),
+ make_option("-n", "--nocontent",
+ dest="no_content",
+ action="store",
+ type="string",
+ help="Avoid index only the content specified by CONTENT_ID."),
)
def handle(self, *args, **options):
content_id = options.get("content_id")
projects = options.get("projects")
+ no_content = options.get("no_content")
if content_id:
self.stdout.write('Creating index for %s\n' % content_id)
@@ -29,9 +35,10 @@
self.stdout.write('Creating contents index...\n')
contentList = Content.objects.all()
count = contentList.count()
-
- indexer = ContentIndexer(contentList, callback=(lambda i,o: show_progress(i+1, count, o.title, 50)))
- indexer.index_all()
+
+ if not no_content;
+ indexer = ContentIndexer(contentList, callback=(lambda i,o: show_progress(i+1, count, o.title, 50)))
+ indexer.index_all()
if projects:
self.stdout.write('Creating projects index...\n')
--- a/src/ldt/ldt/settings.py Wed Feb 27 00:07:54 2013 +0100
+++ b/src/ldt/ldt/settings.py Wed Feb 27 00:12:24 2013 +0100
@@ -35,6 +35,7 @@
'guardian',
'sorl.thumbnail',
'tastypie',
+ 'chunked_uploads',
))
MIDDLEWARE_CLASSES = getattr(settings, 'MIDDLEWARE_CLASSES', (
--- a/src/ldt/ldt/static/ldt/css/ldtform.css Wed Feb 27 00:07:54 2013 +0100
+++ b/src/ldt/ldt/static/ldt/css/ldtform.css Wed Feb 27 00:12:24 2013 +0100
@@ -163,7 +163,7 @@
}
#media_fields_div {
- width : 338px;
+ width : 300px;
height : 50px;
margin-top: 10px 0px;
padding-left: 10px;
--- a/src/ldt/ldt/static/ldt/js/projectscontents.js Wed Feb 27 00:07:54 2013 +0100
+++ b/src/ldt/ldt/static/ldt/js/projectscontents.js Wed Feb 27 00:12:24 2013 +0100
@@ -395,17 +395,11 @@
var h = $(element).innerHeight() + 10;
var w = $(element).innerWidth() + 10;
}
-
+
nm.sizes.minH = h + 10;
nm.sizes.minW = w;
iframe.height(h);
iframe.width(w);
-
- if ($.browser.mozilla && createcontent) {
- $(".nyroModalCont", parent.window.document).height(h+10);
- } else {
- nm.resize(true);
- }
}
//
@@ -421,7 +415,8 @@
$("#close_button").click(function (e) {
e.preventDefault();
parent.$.nmTop().close();
- });
+ });
+
$("#submit_button_write").click(function(e) {
$(".submitcontent-loader-content").show();
resize_modal_window($("#add_content"), true);
@@ -439,103 +434,22 @@
$('#my_form').bind('submit', function() {
window.submit_asked = true;
if($('#id_content-media_input_type').val()=="upload"){
- if(window.upload_from_local_done==false){
- // The form has sent but the uploading has not ended.
- if($('#upload_progress_info').children().size()>0){
- $('#progress_info').remove();
- }
- $('#upload_progress_info').append('<p id="progress_info"><font color="red"><strong>' + wait_label + '.</strong></font><br/><a href="javascript:cancelSwfUpload()">' + cancel_label + '.</a></p>');
- return false;
+ /*if(chunked_upload_complete == true){
+ return true;
}
else{
- return true;
- }
+ return false;
+ }*/
+ return false;
}
else{
- //alert("2. " + $('#id_content-media_input_type').val());
return true;
}
});
- $("#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 {
$('#id_media-local_file_name').val(file.name);
@@ -544,62 +458,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){