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