From 4b636d8be6a0287d8ad0650b93f067f0ac87aef6 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 25 Mar 2015 13:13:09 +0800 Subject: [PATCH] =?UTF-8?q?#1801=20=E6=89=93=E5=8C=85=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=88=86=E4=B8=AA=E6=95=B0=E4=B8=8B=E8=BD=BD=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 4 --- app/controllers/zipdown_controller.rb | 39 ++++++++++++++------- app/views/bids/_homework_list.html.erb | 15 +++++++- public/javascripts/application.js | 28 +++++++++++++++ public/stylesheets/css.css | 14 ++++++-- public/stylesheets/images/img_floatbox.png | Bin 0 -> 1012 bytes 6 files changed, 80 insertions(+), 20 deletions(-) create mode 100644 public/stylesheets/images/img_floatbox.png diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 23d4c3a16..d458b73e4 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -182,8 +182,6 @@ class AttachmentsController < ApplicationController return end - - logger.debug "upload ..... " @attachment = Attachment.new(:file => request.raw_post) @attachment.author = User.current if !params[:project].nil? @@ -192,8 +190,6 @@ class AttachmentsController < ApplicationController end @attachment.filename = params[:filename].presence || Redmine::Utils.random_hex(16) saved = @attachment.save - logger.debug "upload save ..... " - logger.debug @attchement respond_to do |format| format.js diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 75ffe75bd..9880a6382 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -25,17 +25,25 @@ class ZipdownController < ApplicationController zipfile = zip_bid bid else render file: 'public/no_file_found.html' + return end else logger.error "[ZipDown#assort] ===> #{params[:obj_class]} unKown !!" end - if zipfile - if zipfile.length > 1 - @mut_down_files = zipfile.map{|x| File.basename(x)} - else - send_file zipfile, :filename => bid.name + ".zip", :type => detect_content_type(zipfile) - end + # if zipfile + # if zipfile.length > 1 + # @mut_down_files = zipfile #zipfile.each{|x| File.basename(x)} + # else + # send_file zipfile.first[:real_file], :filename => bid.name + ".zip", :type => detect_content_type(zipfile.first[:real_file]) + # return + # end + # end + + respond_to do |format| + format.json { + render json: zipfile.to_json + } end #rescue Exception => e # render file: 'public/no_file_found.html' @@ -86,13 +94,18 @@ class ZipdownController < ApplicationController end end - zips = split_pack_files(bid_homework_path, Setting.pack_attachment_max_size.to_i) + zips = split_pack_files(bid_homework_path, Setting.pack_attachment_max_size.to_i*1024) x = 0 - zips.map { |o| + + zips.each { |o| x += 1 - zipping "#{Time.now.to_i}_#{bid.name}_#{x}.zip", o, OUTPUT_FOLDER + file = zipping "#{Time.now.to_i}_#{bid.name}_#{x}.zip", o[:files], OUTPUT_FOLDER + o[:real_file] = file + o[:file] = File.basename(file) + o[:size] = (File.size(file) / 1024.0 / 1024.0).round(2) } + end def zip_homework_by_user(homeattach) @@ -163,14 +176,14 @@ class ZipdownController < ApplicationController max_size = 0 last_files = [] ret_files = [] - files.each do |f| + files.each_with_index do |f,i| if (max_size += File.size(f)) > pack_attachment_max_size max_size = 0 if last_files.empty? #如果单个文件超过大小,也将此文件作为一组 - ret_files << [f] + ret_files << {files: [f], count: 1, index: ret_files.count+1} last_files.clear else - ret_files << last_files + ret_files << {files:last_files, count: last_files.count, index: ret_files.count+1} last_files.clear redo end @@ -179,7 +192,7 @@ class ZipdownController < ApplicationController end end - ret_files << last_files unless last_files.empty? + ret_files << {files:last_files, count: last_files.count, index: ret_files.count+1} unless last_files.empty? ret_files end diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 6572ee2c9..7ac686e09 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -23,7 +23,7 @@ (<%= @jours_count %>)