1.打包下载异常捕获去除

2.打包下载寻找课程、项目方法隐藏
This commit is contained in:
sw 2015-01-10 10:55:37 +08:00
parent a30cc9bea8
commit f4e30f77cc
1 changed files with 18 additions and 18 deletions

View File

@ -7,17 +7,6 @@ class ZipdownController < ApplicationController
SAVE_FOLDER = "#{Rails.root}/files"
OUTPUT_FOLDER = "#{Rails.root}/tmp/archiveZip"
#通过作业Id找到项目课程
def find_project_by_bid_id
obj_class = params[:obj_class]
obj_id = params[:obj_id]
obj = obj_class.constantize.find(obj_id)
case obj.class.to_s.to_sym
when :Bid
@project = obj.courses[0]
end
end
def assort
if params[:obj_class] == "Bid"
bid = Bid.find params[:obj_id]
@ -33,8 +22,8 @@ class ZipdownController < ApplicationController
end
send_file zipfile, :filename => bid.name + ".zip", :type => detect_content_type(zipfile) if zipfile
rescue Exception => e
render file: 'public/no_file_found.html'
#rescue Exception => e
# render file: 'public/no_file_found.html'
end
#下载某一学生的作业的所有文件
@ -56,12 +45,23 @@ class ZipdownController < ApplicationController
else
render_403
end
rescue => e
render file: 'public/file_not_found.html'
#rescue => e
# render file: 'public/file_not_found.html'
end
private
#通过作业Id找到项目课程
def find_project_by_bid_id
obj_class = params[:obj_class]
obj_id = params[:obj_id]
obj = obj_class.constantize.find(obj_id)
case obj.class.to_s.to_sym
when :Bid
@project = obj.courses[0]
end
end
def zip_bid(bid)
# Todo: User Access Controll
bid_homework_path = []
@ -113,9 +113,9 @@ class ZipdownController < ApplicationController
end
end
zipfile_name
rescue Errno => e
logger.error "[zipdown#zipping] ===> #{e}"
@error = e
#rescue Errno => e
# logger.error "[zipdown#zipping] ===> #{e}"
# @error = e
end
def detect_content_type(name)
content_type = Redmine::MimeType.of(name)