发送过来的资源在项目中添加动态

This commit is contained in:
huang 2016-07-15 11:31:31 +08:00
parent 97b1ea22e7
commit 38cc3c2010
1 changed files with 6 additions and 0 deletions

View File

@ -2132,6 +2132,7 @@ class UsersController < ApplicationController
# 添加资源到对应的项目
def add_exist_file_to_project
@flag = true
# 发送单个资源
if params[:send_id].present?
send_id = params[:send_id]
project_ids = params[:projects_ids]
@ -2168,6 +2169,8 @@ class UsersController < ApplicationController
quotes = ori.quotes.to_i + 1
ori.update_attribute(:quotes, quotes) unless ori.nil?
ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
# 项目中添加动态
ForgeActivity.create(:user_id => User.current.id, :project_id => project_id, :forge_act_id => attach_copied_obj.id, :forge_act_type => "Attachment" )
end
unless Project.find(project_id).project_score.nil?
Project.find(project_id).project_score.update_attribute(:attach_num,
@ -2176,6 +2179,7 @@ class UsersController < ApplicationController
end
@ori = ori
end
# 发送多个资源
elsif params[:send_ids].present?
send_ids = params[:send_ids].split(",")
project_ids = params[:projects_ids]
@ -2214,6 +2218,8 @@ class UsersController < ApplicationController
quotes = ori.quotes.to_i + 1
ori.update_attribute(:quotes, quotes) unless ori.nil?
ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
# 项目中添加动态
ForgeActivity.create(:user_id => User.current.id, :project_id => project_id, :forge_act_id => attach_copied_obj.id, :forge_act_type => "Attachment" )
end
unless Project.find(project_id).project_score.nil?
Project.find(project_id).project_score.update_attribute(:attach_num, Project.find(project_id).project_score.attach_num + 1)