附件引用

This commit is contained in:
huang 2016-03-04 14:21:39 +08:00
parent 9beaa62d6d
commit dfddb30ca3
1 changed files with 23 additions and 3 deletions

View File

@ -1658,6 +1658,9 @@ class UsersController < ApplicationController
attach_copied_obj.attachtype = 4
end
if attach_copied_obj.save
# 更新引用次数
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)
end
@save_message = attach_copied_obj.errors.full_messages
@ -1670,10 +1673,11 @@ class UsersController < ApplicationController
@flag = false
end
send_ids.each do |send_id|
quotes = 0
ori = Attachment.find_by_id(send_id)
unless course_ids.nil?
course_ids.each do |id|
quotes = 0
next if ori.blank?
@exist = false
Course.find(id).attachments.each do |att| #如果课程中包含该资源
@ -1696,6 +1700,9 @@ class UsersController < ApplicationController
attach_copied_obj.attachtype = 4
end
if attach_copied_obj.save
# 更新引用次数
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)
end
@save_message = attach_copied_obj.errors.full_messages
@ -1756,6 +1763,9 @@ class UsersController < ApplicationController
attach_copied_obj.attachtype = 1
end
if attach_copied_obj.save
# 更新引用次数
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)
end
unless Project.find(project_id).project_score.nil?
@ -1771,10 +1781,11 @@ class UsersController < ApplicationController
@flag = false
end
send_ids.each do |send_id|
quotes = 0
ori = Attachment.find_by_id(send_id)
unless project_ids.nil?
project_ids.each do |project_id|
quotes = 0
next if ori.blank?
@exist = false
Project.find(project_id).attachments.each do |att| #如果课程中包含该资源
@ -1797,6 +1808,9 @@ class UsersController < ApplicationController
attach_copied_obj.attachtype = 1
end
if attach_copied_obj.save
# 更新引用次数
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)
end
unless Project.find(project_id).project_score.nil?
@ -1856,6 +1870,9 @@ class UsersController < ApplicationController
attach_copied_obj.attachtype = 1
end
if attach_copied_obj.save
# 更新引用次数
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)
end
end
@ -1867,7 +1884,7 @@ class UsersController < ApplicationController
@flag = false
end
send_ids.each do |send_id|
quotes = 0
ori = Attachment.find_by_id(send_id)
unless subfield_id.nil?
next if ori.blank?
@ -1892,6 +1909,9 @@ class UsersController < ApplicationController
attach_copied_obj.attachtype = 1
end
if attach_copied_obj.save
# 更新引用次数
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)
end
end