From 7967066b05db8bc4568f1a715ea1b0e086ec61a9 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 22 Mar 2016 15:06:54 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=84=E4=BB=B6=E6=B7=BB=E5=8A=A0=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E5=8F=91=E9=80=81=E6=96=B9=E5=BC=8F=E6=94=B9=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 13 +++++++------ app/models/attachment.rb | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 7ae1b85f8..69b356b5a 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -458,10 +458,16 @@ class FilesController < ApplicationController if params[:in_project_toolbar] @in_project_toolbar = params[:in_project_toolbar] end - # 发送邮件 attachments = Attachment.attach_filesex(@project, params[:attachments], params[:attachment_type]) if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') + # 发送邮件 Mailer.run.attachments_added(attachments[:files]) + # 生成动态 + attachments[:files].each do |file| + ForgeActivity.create(:user_id => User.current.id, :project_id => @project.id, :forge_act_id => file.id, :forge_act_type => "Attachment") + end + # 更新资源总数, 根据上传的附件数累加 + @project.project_score.update_attribute(:attach_num, @project.project_score.attach_num + attachments[:files].count) unless @project.project_score.nil? end # end if params[:project_attachment_type] && params[:project_attachment_type].is_a?(Array) @@ -485,11 +491,6 @@ class FilesController < ApplicationController end end end - # 更新资源总数, 根据上传的附件数累加 - unless @project.project_score.nil? - @project.project_score.update_attribute(:attach_num, @project.project_score.attach_num + attachments[:files].count) - end - # end # TODO: 临时用 nyan sort_init 'created_on', 'desc' sort_update 'created_on' => "#{Attachment.table_name}.created_on", diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 714da9920..881621c3a 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -90,7 +90,7 @@ class Attachment < ActiveRecord::Base @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails") before_save :files_to_final_location - after_save :act_as_course_activity,:act_as_forge_activity + after_save :act_as_course_activity after_create :office_conver, :be_user_score,:create_attachment_ealasticsearch_index after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count, :down_course_score