From 7290cc000a06f4329dafe640e84438cb183c2887 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 7 Jan 2020 09:44:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E7=89=88=E7=9A=84=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E9=99=84=E4=BB=B6=E6=89=93=E5=8C=85=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/export_helper.rb | 2 +- lib/tasks/zip_pack.rake | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index ca76ee953..22adf3005 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -850,7 +850,7 @@ module ExportHelper def make_zip_name(work, file_name="") Rails.logger.info("######################file_name: #{file_name}") # name = file_name === "" ? "" : (file_name[0, file_name.rindex('.')]+"_") - "#{work&.user&.student_id}_#{work&.user&.real_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" + "#{work&.homework_common.course&.user_group_name(work.user_id)}_#{work&.user&.student_id}_#{work&.user&.real_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" end def zipping(zip_name_refer, files_paths, output_path, is_attachment=false, not_exist_file=[]) diff --git a/lib/tasks/zip_pack.rake b/lib/tasks/zip_pack.rake index c1a080e36..393f7ab3c 100644 --- a/lib/tasks/zip_pack.rake +++ b/lib/tasks/zip_pack.rake @@ -46,6 +46,21 @@ namespace :zip_pack do end end + task :homework_attach_pack => :environment do + include ExportHelper + if ENV['args'] + homework_id = ENV['args'] + homework = HomeworkCommon.find homework_id + zip_works = homework.student_works.where("work_status > 0") + if zip_works.size > 0 + zipfile = zip_homework_common homework, zip_works + else + zipfile = {:message => "no file"} + end + puts "out: #{zipfile}" + end + end + def filename_for_content_disposition(name) request.env['HTTP_USER_AGENT'] =~ %r{MSIE|Trident|Edge} ? ERB::Util.url_encode(name) : name end