parent
a30cc9bea8
commit
f4e30f77cc
|
@ -7,17 +7,6 @@ class ZipdownController < ApplicationController
|
||||||
SAVE_FOLDER = "#{Rails.root}/files"
|
SAVE_FOLDER = "#{Rails.root}/files"
|
||||||
OUTPUT_FOLDER = "#{Rails.root}/tmp/archiveZip"
|
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
|
def assort
|
||||||
if params[:obj_class] == "Bid"
|
if params[:obj_class] == "Bid"
|
||||||
bid = Bid.find params[:obj_id]
|
bid = Bid.find params[:obj_id]
|
||||||
|
@ -33,8 +22,8 @@ class ZipdownController < ApplicationController
|
||||||
end
|
end
|
||||||
send_file zipfile, :filename => bid.name + ".zip", :type => detect_content_type(zipfile) if zipfile
|
send_file zipfile, :filename => bid.name + ".zip", :type => detect_content_type(zipfile) if zipfile
|
||||||
|
|
||||||
rescue Exception => e
|
#rescue Exception => e
|
||||||
render file: 'public/no_file_found.html'
|
# render file: 'public/no_file_found.html'
|
||||||
end
|
end
|
||||||
|
|
||||||
#下载某一学生的作业的所有文件
|
#下载某一学生的作业的所有文件
|
||||||
|
@ -56,12 +45,23 @@ class ZipdownController < ApplicationController
|
||||||
else
|
else
|
||||||
render_403
|
render_403
|
||||||
end
|
end
|
||||||
rescue => e
|
#rescue => e
|
||||||
render file: 'public/file_not_found.html'
|
# render file: 'public/file_not_found.html'
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
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)
|
def zip_bid(bid)
|
||||||
# Todo: User Access Controll
|
# Todo: User Access Controll
|
||||||
bid_homework_path = []
|
bid_homework_path = []
|
||||||
|
@ -113,9 +113,9 @@ class ZipdownController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
zipfile_name
|
zipfile_name
|
||||||
rescue Errno => e
|
#rescue Errno => e
|
||||||
logger.error "[zipdown#zipping] ===> #{e}"
|
# logger.error "[zipdown#zipping] ===> #{e}"
|
||||||
@error = e
|
# @error = e
|
||||||
end
|
end
|
||||||
def detect_content_type(name)
|
def detect_content_type(name)
|
||||||
content_type = Redmine::MimeType.of(name)
|
content_type = Redmine::MimeType.of(name)
|
||||||
|
|
Loading…
Reference in New Issue