当作品中没有附件时,下载报错

redis_cache
sw 10 years ago
parent a881343db5
commit f7b3229065

@ -30,8 +30,7 @@ class ZipdownController < ApplicationController
if file_count > 0
zipfile = zip_bid bid
else
render file: 'public/no_file_found.html'
return
zipfile = {:message => "no file"}
end
elsif params[:obj_class] == "HomeworkCommon"
homework = HomeworkCommon.find params[:obj_id]
@ -41,8 +40,7 @@ class ZipdownController < ApplicationController
if file_count > 0
zipfile = zip_homework_common homework
else
render file: 'public/no_file_found.html'
return
zipfile = {:message => "no file"}
end
else
logger.error "[ZipDown#assort] ===> #{params[:obj_class]} unKown !!"

@ -901,24 +901,30 @@ $(function(){
$('#download_homework_attachments').bind('ajax:complete', function (event, data, status, xhr) {
if(status == 'success'){
var res = JSON.parse(data.responseText);
if(res.length<1){
return;
if(res.length == null){
alert("该作业没有任何附件可下载");
}
if(res.length==1){
location.href = '/zipdown/download?file='+res[0].file;return;
else if(res.length<1){
return;
}
document.getElementById('light').style.display='block';
$container = $('#light .upload_box_ul');
$container.empty();
for(var i = 0; i <res.length; ++i){
var des = '';
if(res.count > 1){
des = '第'+res[i].index+'-'+(res[i].count+res[i].index-1)+'个学生的作品下载';
} else {
des = '第'+res[i].index+'个学生的作品下载';
else
{
if(res.length==1){
location.href = '/zipdown/download?file='+res[0].file;return;
}
$('<li><span class="upload_box_span" >'+(i+1)+'.</span> <a href="/zipdown/download?file='+res[i].file+'">'+des+'</a><span class="c_grey">&nbsp;&nbsp;(共'+res[i].size+'M</span> </li>').appendTo($container);
document.getElementById('light').style.display='block';
$container = $('#light .upload_box_ul');
$container.empty();
for(var i = 0; i <res.length; ++i){
var des = '';
if(res.count > 1){
des = '第'+res[i].index+'-'+(res[i].count+res[i].index-1)+'个学生的作品下载';
} else {
des = '第'+res[i].index+'个学生的作品下载';
}
$('<li><span class="upload_box_span" >'+(i+1)+'.</span> <a href="/zipdown/download?file='+res[i].file+'">'+des+'</a><span class="c_grey">&nbsp;&nbsp;(共'+res[i].size+'M</span> </li>').appendTo($container);
}
}
}
});

Loading…
Cancel
Save