From 2827bd0c2190782611e3b489c2efd20dbe66331a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 9 Jun 2014 11:28:30 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E4=B8=8B=E8=BD=BD=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=BD=9C=E4=B8=9A=E6=89=80=E6=9C=89=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E4=BC=A0=E9=80=92=E5=8F=82=E6=95=B0=202.?= =?UTF-8?q?=E5=87=8F=E5=B0=91=E4=B8=8B=E8=BD=BD=E5=90=8E=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=9A=84=E6=89=93=E5=8C=85=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/zipdown_controller.rb | 22 +++++++--------------- app/views/bids/_homework_list.html.erb | 2 +- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 5caa97a22..b10b47aaa 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -22,20 +22,10 @@ class ZipdownController < ApplicationController #下载某一学生的作业的所有文件 def download_user_homework - obj_class = params[:obj_class] - obj_id = params[:obj_id] - user_id = params[:user_id] - obj = obj_class.constantize.find(obj_id) - - if User.current.admin? || User.current.member_of?(obj.courses.first) - zipfile = nil - case obj.class.to_s.to_sym - when :Bid - zipfile = zip_user_bid obj,user_id - else - logger.error "[ZipDown#assort] ===> #{obj.class.to_s.to_sym} unKown !!" - end - send_file zipfile, :filename => obj.name, :type => detect_content_type(zipfile) if zipfile + homework = HomeworkAttach.find params[:homework] + if homework != nil && (User.current.admin? || User.current.member_of?(homework.bid.courses.first)) + zipfile = zip_homework_by_user homework + send_file zipfile, :filename => homework.name, :type => detect_content_type(zipfile) if zipfile else render_403 :message => :notice_not_authorized end @@ -52,7 +42,8 @@ class ZipdownController < ApplicationController user_zip_paths = homeattaches.map do |homeattach| zip_homework_by_user homeattach end - zipping "#{Time.now.to_i}_#{bid.name}.zip", user_zip_paths, OUTPUT_FOLDER + #zipping "#{Time.now.to_i}_#{bid.name}.zip", user_zip_paths, OUTPUT_FOLDER + user_zip_paths end def zip_bid(bid) @@ -84,6 +75,7 @@ class ZipdownController < ApplicationController homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1) end zipping "#{Time.now.to_i}_#{homeattach.user.name.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true + #user_attaches_paths end diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index a7d65ea43..f1fd0b7b7 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -49,7 +49,7 @@ <% end %> <% if is_evaluation || is_teacher%> - <%= link_to homework_filename, :controller => "zipdown", :action => "download_user_homework",:obj_class => @bid.class,:obj_id => @bid, :user_id =>homework.user%> + <%= link_to homework_filename, :controller => "zipdown", :action => "download_user_homework",:homework => homework%> <% else %> <%= homework_filename %> <% end %>