Update copy experiment permission checks [SCI-6147] (#3598)

Co-authored-by: Anton <anton@scinote.net>
This commit is contained in:
aignatov-bio 2021-10-26 11:40:54 +02:00 committed by GitHub
parent 80b5018337
commit edb09dd099
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 10 deletions

View file

@ -21,14 +21,16 @@ class MyModuleGroup < ApplicationRecord
) )
# Get clones of modules from this group, save them as hash # Get clones of modules from this group, save them as hash
cloned_modules = my_modules.workflow_ordered.each_with_object({}) do |m, h| cloned_modules = my_modules.readable_by_user(current_user).workflow_ordered.each_with_object({}) do |m, h|
h[m.id] = m.deep_clone_to_experiment(current_user, experiment) h[m.id] = m.deep_clone_to_experiment(current_user, experiment)
h h
end end
my_modules.workflow_ordered.each do |m| my_modules.readable_by_user(current_user).workflow_ordered.each do |m|
# Copy connections # Copy connections
m.inputs.each do |inp| m.inputs.each do |inp|
next if cloned_modules[inp[:input_id]].nil? || cloned_modules[inp[:output_id]].nil?
Connection.create( Connection.create(
input_id: cloned_modules[inp[:input_id]].id, input_id: cloned_modules[inp[:input_id]].id,
output_id: cloned_modules[inp[:output_id]].id output_id: cloned_modules[inp[:output_id]].id

View file

@ -29,7 +29,7 @@ module Experiments
) )
# Copy all signle taskas # Copy all signle taskas
@c_exp.my_modules << @exp.my_modules.without_group.map do |m| @c_exp.my_modules << @exp.my_modules.readable_by_user(@user).without_group.map do |m|
m.deep_clone_to_experiment(@user, @c_exp) m.deep_clone_to_experiment(@user, @c_exp)
end end
@ -38,13 +38,6 @@ module Experiments
@c_exp.my_module_groups << g.deep_clone_to_experiment(@user, @c_exp) @c_exp.my_module_groups << g.deep_clone_to_experiment(@user, @c_exp)
end end
# Copy user assignments to the experiment
@exp.user_assignments.map do |user_assignment|
new_user_assigment = user_assignment.dup
new_user_assigment.assignable = @c_exp
new_user_assigment.save!
end
@c_exp.save! @c_exp.save!
end end
@errors.merge!(@c_exp.errors.to_hash) unless @c_exp.valid? @errors.merge!(@c_exp.errors.to_hash) unless @c_exp.valid?