mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-20 14:45:56 +08:00
Update copy experiment permission checks [SCI-6147] (#3598)
Co-authored-by: Anton <anton@scinote.net>
This commit is contained in:
parent
80b5018337
commit
edb09dd099
|
@ -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
|
||||||
|
|
|
@ -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?
|
||||||
|
|
Loading…
Reference in a new issue