公共资源库,点击底部不能发送的问题
This commit is contained in:
parent
f806dbf587
commit
92f55e0dc1
|
@ -1942,7 +1942,7 @@ class UsersController < ApplicationController
|
||||||
# 将资源发送到对应的课程,分为发送单个,或者批量发送
|
# 将资源发送到对应的课程,分为发送单个,或者批量发送
|
||||||
def add_exist_file_to_course
|
def add_exist_file_to_course
|
||||||
@flag = true
|
@flag = true
|
||||||
if params[:send_id].present?
|
if params[:send_id].present?
|
||||||
send_id = params[:send_id]
|
send_id = params[:send_id]
|
||||||
@ori = Attachment.find_by_id(send_id)
|
@ori = Attachment.find_by_id(send_id)
|
||||||
course_ids = params[:course_ids]
|
course_ids = params[:course_ids]
|
||||||
|
@ -1989,14 +1989,14 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
send_ids.each do |send_id|
|
send_ids.each do |send_id|
|
||||||
quotes = 0
|
quotes = 0
|
||||||
ori = Attachment.find_by_id(send_id)
|
@ori = Attachment.find_by_id(send_id)
|
||||||
unless course_ids.nil?
|
unless course_ids.nil?
|
||||||
course_ids.each do |id|
|
course_ids.each do |id|
|
||||||
quotes = 0
|
quotes = 0
|
||||||
next if ori.blank?
|
next if @ori.blank?
|
||||||
@exist = false
|
@exist = false
|
||||||
Course.find(id).attachments.each do |att| #如果课程中包含该资源
|
Course.find(id).attachments.each do |att| #如果课程中包含该资源
|
||||||
if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
|
if att.id == @ori.id || (!att.copy_from.nil? && !@ori.copy_from.nil? && att.copy_from == @ori.copy_from) || att.copy_from == @ori.id || att.id == @ori.copy_from
|
||||||
att.created_on = Time.now
|
att.created_on = Time.now
|
||||||
att.save
|
att.save
|
||||||
@exist = true
|
@exist = true
|
||||||
|
@ -2004,21 +2004,21 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
next if @exist
|
next if @exist
|
||||||
attach_copied_obj = ori.copy
|
attach_copied_obj = @ori.copy
|
||||||
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
|
attach_copied_obj.tag_list.add(@ori.tag_list) # tag关联
|
||||||
attach_copied_obj.container = Course.find(id)
|
attach_copied_obj.container = Course.find(id)
|
||||||
attach_copied_obj.created_on = Time.now
|
attach_copied_obj.created_on = Time.now
|
||||||
attach_copied_obj.author_id = User.current.id
|
attach_copied_obj.author_id = User.current.id
|
||||||
attach_copied_obj.is_public = 0
|
attach_copied_obj.is_public = 0
|
||||||
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
|
attach_copied_obj.copy_from = @ori.copy_from.nil? ? @ori.id : @ori.copy_from #发送要添加copy_from
|
||||||
if attach_copied_obj.attachtype == nil
|
if attach_copied_obj.attachtype == nil
|
||||||
attach_copied_obj.attachtype = 4
|
attach_copied_obj.attachtype = 4
|
||||||
end
|
end
|
||||||
if attach_copied_obj.save
|
if attach_copied_obj.save
|
||||||
# 更新引用次数
|
# 更新引用次数
|
||||||
quotes = ori.quotes.to_i + 1
|
quotes = @ori.quotes.to_i + 1
|
||||||
ori.update_attribute(:quotes, quotes) unless ori.nil?
|
@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)
|
@ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
|
||||||
end
|
end
|
||||||
@save_message = attach_copied_obj.errors.full_messages
|
@save_message = attach_copied_obj.errors.full_messages
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue