不允许重复发送。但是发送过程不会给予提示。如果课程或者项目或者组织已经有了该资源,那么该资源的更新时间会变化
This commit is contained in:
parent
57ef7a2d4a
commit
fccbbe6e2b
|
@ -1489,6 +1489,16 @@ class UsersController < ApplicationController
|
|||
unless course_ids.nil?
|
||||
course_ids.each do |id|
|
||||
next if ori.blank?
|
||||
@exist = false
|
||||
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
|
||||
att.created_on = Time.now
|
||||
att.save
|
||||
@exist = true
|
||||
break
|
||||
end
|
||||
end
|
||||
next if @exist
|
||||
attach_copied_obj = ori.copy
|
||||
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
|
||||
attach_copied_obj.container = Course.find(id)
|
||||
|
@ -1515,6 +1525,16 @@ class UsersController < ApplicationController
|
|||
unless course_ids.nil?
|
||||
course_ids.each do |id|
|
||||
next if ori.blank?
|
||||
@exist = false
|
||||
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
|
||||
att.created_on = Time.now
|
||||
att.save
|
||||
@exist = true
|
||||
break
|
||||
end
|
||||
end
|
||||
next if @exist
|
||||
attach_copied_obj = ori.copy
|
||||
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
|
||||
attach_copied_obj.container = Course.find(id)
|
||||
|
@ -1563,6 +1583,16 @@ class UsersController < ApplicationController
|
|||
unless project_ids.nil?
|
||||
project_ids.each do |project_id|
|
||||
next if ori.blank?
|
||||
@exist = false
|
||||
Project.find(project_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
|
||||
att.created_on = Time.now
|
||||
att.save
|
||||
@exist = true
|
||||
break
|
||||
end
|
||||
end
|
||||
next if @exist
|
||||
attach_copied_obj = ori.copy
|
||||
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
|
||||
attach_copied_obj.container = Project.find(project_id)
|
||||
|
@ -1588,6 +1618,16 @@ class UsersController < ApplicationController
|
|||
unless project_ids.nil?
|
||||
project_ids.each do |project_id|
|
||||
next if ori.blank?
|
||||
@exist = false
|
||||
Project.find(project_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
|
||||
att.created_on = Time.now
|
||||
att.save
|
||||
@exist = true
|
||||
break
|
||||
end
|
||||
end
|
||||
next if @exist
|
||||
attach_copied_obj = ori.copy
|
||||
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
|
||||
attach_copied_obj.container = Project.find(project_id)
|
||||
|
@ -1633,16 +1673,27 @@ class UsersController < ApplicationController
|
|||
ori = Attachment.find_by_id(send_id)
|
||||
unless subfield_id.nil?
|
||||
attach_copied_obj = ori.copy
|
||||
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
|
||||
attach_copied_obj.container = OrgSubfield.find(subfield_id)
|
||||
attach_copied_obj.created_on = Time.now
|
||||
attach_copied_obj.author_id = User.current.id
|
||||
attach_copied_obj.is_public = 0
|
||||
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
|
||||
if attach_copied_obj.attachtype == nil
|
||||
attach_copied_obj.attachtype = 1
|
||||
@exist = false
|
||||
OrgSubfield.find(subfield_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
|
||||
att.created_on = Time.now
|
||||
att.save
|
||||
@exist = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if @exist == false #如果不存在该资源
|
||||
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
|
||||
attach_copied_obj.container = OrgSubfield.find(subfield_id)
|
||||
attach_copied_obj.created_on = Time.now
|
||||
attach_copied_obj.author_id = User.current.id
|
||||
attach_copied_obj.is_public = 0
|
||||
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
|
||||
if attach_copied_obj.attachtype == nil
|
||||
attach_copied_obj.attachtype = 1
|
||||
end
|
||||
attach_copied_obj.save
|
||||
end
|
||||
attach_copied_obj.save
|
||||
end
|
||||
elsif params[:send_ids].present?
|
||||
send_ids = params[:send_ids].split(" ")
|
||||
|
@ -1655,6 +1706,16 @@ class UsersController < ApplicationController
|
|||
ori = Attachment.find_by_id(send_id)
|
||||
unless subfield_id.nil?
|
||||
next if ori.blank?
|
||||
@exist = false
|
||||
OrgSubfield.find(subfield_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
|
||||
att.created_on = Time.now
|
||||
att.save
|
||||
@exist = true
|
||||
break
|
||||
end
|
||||
end
|
||||
next if @exist
|
||||
attach_copied_obj = ori.copy
|
||||
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
|
||||
attach_copied_obj.container = OrgSubfield.find(subfield_id)
|
||||
|
|
Loading…
Reference in New Issue