forked from spen/seminar
Fix bug.
This commit is contained in:
parent
f83fb71f2a
commit
7e203b6863
|
@ -343,7 +343,7 @@ class Admin::SeminarsController < OrbitAdminController
|
||||||
seminar.create_user_id = current_user.id
|
seminar.create_user_id = current_user.id
|
||||||
seminar.update_user_id = current_user.id
|
seminar.update_user_id = current_user.id
|
||||||
if seminar.copy_id && params["clone_signups"].blank?
|
if seminar.copy_id && params["clone_signups"].blank?
|
||||||
seminar.except_clone_relations = ["seminar_signups","seminar_signup_values"]
|
seminar.except_clone_relations = ["seminar_signups","seminar_signup_values","seminar_signup_contributes","seminar_submission_values"]
|
||||||
end
|
end
|
||||||
seminar.save
|
seminar.save
|
||||||
if seminar.copy_id
|
if seminar.copy_id
|
||||||
|
|
|
@ -309,6 +309,7 @@ def clone_new_for_object(object,clone_target=nil,clone_mode=false)
|
||||||
clone_target = object if clone_target.nil?
|
clone_target = object if clone_target.nil?
|
||||||
new_object = object.dup
|
new_object = object.dup
|
||||||
end
|
end
|
||||||
|
return if self.except_clone_relations.to_s.include?(new_object.class.to_s.underscore)
|
||||||
@records_all["#{new_object.class.to_s.underscore.singularize}_ids"] = {} if @records_all["#{new_object.class.to_s.underscore.singularize}_ids"].nil?
|
@records_all["#{new_object.class.to_s.underscore.singularize}_ids"] = {} if @records_all["#{new_object.class.to_s.underscore.singularize}_ids"].nil?
|
||||||
begin
|
begin
|
||||||
@records_all["#{new_object.class.to_s.underscore.singularize}_ids"][clone_target.id] = object.id
|
@records_all["#{new_object.class.to_s.underscore.singularize}_ids"][clone_target.id] = object.id
|
||||||
|
@ -372,6 +373,7 @@ def clone_new_for_object(object,clone_target=nil,clone_mode=false)
|
||||||
end
|
end
|
||||||
relations_fields = tmp_relations_fields
|
relations_fields = tmp_relations_fields
|
||||||
fields_to_delete.each{|f| relations_fields.delete(f)}
|
fields_to_delete.each{|f| relations_fields.delete(f)}
|
||||||
|
@clone_mode = clone_mode
|
||||||
end
|
end
|
||||||
@parent_level = true
|
@parent_level = true
|
||||||
if clone_mode
|
if clone_mode
|
||||||
|
@ -396,7 +398,7 @@ def clone_new_for_object(object,clone_target=nil,clone_mode=false)
|
||||||
new_object.send("#{f}_id=",(@records_all["#{f}_ids"][clone_target.send("#{f}_id")]))
|
new_object.send("#{f}_id=",(@records_all["#{f}_ids"][clone_target.send("#{f}_id")]))
|
||||||
end
|
end
|
||||||
elsif clone_target.relations[f].macro == :has_many
|
elsif clone_target.relations[f].macro == :has_many
|
||||||
next if self.except_clone_relations.include?(f)
|
next if self.except_clone_relations.to_s.include?(f)
|
||||||
clone_relations = []
|
clone_relations = []
|
||||||
need_clone_relations = clone_target.send(f).asc(:_id).to_a
|
need_clone_relations = clone_target.send(f).asc(:_id).to_a
|
||||||
file_flag = false
|
file_flag = false
|
||||||
|
@ -409,14 +411,16 @@ def clone_new_for_object(object,clone_target=nil,clone_mode=false)
|
||||||
check_fields = clone_relation.fields.except(initialize_fields)
|
check_fields = clone_relation.fields.except(initialize_fields)
|
||||||
check_fields.keys.each do |f|
|
check_fields.keys.each do |f|
|
||||||
if (clone_relation.send(f).class.to_s.match(/uploader/i) rescue false)
|
if (clone_relation.send(f).class.to_s.match(/uploader/i) rescue false)
|
||||||
if clone_relation[f].blank?
|
if clone_relation[f].blank? && (clone_relation.send(f).file.nil? rescue true)
|
||||||
clone_relation[f] = r[f]
|
clone_relation[f] = r[f]
|
||||||
source_filepath = r.send(f).file.file
|
source_filepath = r.send(f).file.file
|
||||||
if clone_mode
|
if @clone_mode
|
||||||
dest_filepath = clone_relation.send(f).file.file
|
dest_filepath = clone_relation.send(f).file.file
|
||||||
FileUtils.mkdir_p(File.dirname(dest_filepath))
|
FileUtils.mkdir_p(File.dirname(dest_filepath))
|
||||||
FileUtils.cp(source_filepath,dest_filepath)
|
FileUtils.cp(source_filepath,dest_filepath)
|
||||||
end
|
end
|
||||||
|
elsif (clone_relation.send(f).file rescue nil)
|
||||||
|
clone_relation[f] = File.basename(clone_relation.send(f).file.file.to_s)
|
||||||
end
|
end
|
||||||
file_flag = true
|
file_flag = true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue