Merge pull request #1615 from jbargu/jg_sci_3252

Change breadcrumbs for copy as template experiment, missing activity for move workflow [SCI-3252]
This commit is contained in:
Jure Grabnar 2019-04-01 12:30:48 +02:00 committed by GitHub
commit 111b0e2b7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 4 deletions

View file

@ -210,7 +210,7 @@ class Experiment < ApplicationRecord
move_modules(updated_to_move, current_user)
# Everyhing is set, now we can move any module groups
move_module_groups(updated_to_move_groups)
move_module_groups(updated_to_move_groups, current_user)
end
rescue ActiveRecord::ActiveRecordError,
ArgumentError,
@ -365,7 +365,7 @@ class Experiment < ApplicationRecord
# If a module with given ID doesn't exist (or experiment ID)
# it's obviously not updated. Position for entire module group is updated
# to bottom left corner.
def move_module_groups(to_move)
def move_module_groups(to_move, current_user)
to_move.each do |ids, experiment_id|
modules = my_modules.find(ids)
groups = Set.new(modules.map(&:my_module_group))
@ -391,8 +391,23 @@ class Experiment < ApplicationRecord
modules.each { |m| m.y += -curr_min_y + max_y }
modules.each do |m|
experiment_org = m.experiment
m.experiment = experiment
m.save!
# Add activity
Activities::CreateActivityService.call(
activity_type: :move_task,
owner: current_user,
subject: m,
project: experiment.project,
team: experiment.project.team,
message_items: {
my_module: m.id,
experiment_original: experiment_org.id,
experiment_new: experiment.id
}
)
end
group.experiment = experiment

View file

@ -90,8 +90,8 @@ module Experiments
.call(activity_type: :clone_experiment,
owner: @user,
team: @project.team,
project: @project,
subject: @exp,
project: @c_exp.project,
subject: @c_exp,
message_items: { experiment_new: @c_exp.id,
experiment_original: @exp.id })
end