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

redis_cache
sw 10 years ago
parent a881343db5
commit f7b3229065

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

@ -901,9 +901,14 @@ $(function(){
$('#download_homework_attachments').bind('ajax:complete', function (event, data, status, xhr) { $('#download_homework_attachments').bind('ajax:complete', function (event, data, status, xhr) {
if(status == 'success'){ if(status == 'success'){
var res = JSON.parse(data.responseText); var res = JSON.parse(data.responseText);
if(res.length<1){ if(res.length == null){
alert("该作业没有任何附件可下载");
}
else if(res.length<1){
return; return;
} }
else
{
if(res.length==1){ if(res.length==1){
location.href = '/zipdown/download?file='+res[0].file;return; location.href = '/zipdown/download?file='+res[0].file;return;
} }
@ -921,6 +926,7 @@ $(function(){
} }
} }
}
}); });
}); });

Loading…
Cancel
Save