附件添加动态发送方式改变

This commit is contained in:
huang 2016-03-22 15:06:54 +08:00
parent 478311128d
commit 7967066b05
2 changed files with 8 additions and 7 deletions

View File

@ -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",

View File

@ -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