修复老师角色在没有任何附件情况下点击打包下载报500错误的BUG #1209

解决方案:增加判断是否有一个以上附件,当没有任何附件时,提示用户没有任何文件可以下载
This commit is contained in:
sw 2014-09-10 11:14:38 +08:00
parent 67737d8dd9
commit dec8b70895
1 changed files with 6 additions and 0 deletions

View File

@ -76,13 +76,19 @@ class ZipdownController < ApplicationController
# Todo: User Access Controll
homeattaches = bid.homeworks
#记录所有作业是不是有附件有一个附件就改为true
has_file = false
# 得到每一个人所有文件打包的zip文件
# 并将每一个人的zip打包为一个并返回路径
user_zip_paths = homeattaches.map do |homeattach|
if homeattach.attachments.count > 0
zip_homework_by_user homeattach
has_file = true if has_file == false
end
end
render_403 :message => :no_file_dowmload ,:layout => "course_base" if has_file == false
zipping "#{Time.now.to_i}_#{bid.name}.zip", user_zip_paths, OUTPUT_FOLDER
#@paths = homeworks_attach_path