diff --git a/app/models/experiment.rb b/app/models/experiment.rb index e5aab7b8e..f30ad9fad 100644 --- a/app/models/experiment.rb +++ b/app/models/experiment.rb @@ -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 diff --git a/app/services/experiments/copy_experiment_as_template_service.rb b/app/services/experiments/copy_experiment_as_template_service.rb index 156266ea6..c49e28e12 100644 --- a/app/services/experiments/copy_experiment_as_template_service.rb +++ b/app/services/experiments/copy_experiment_as_template_service.rb @@ -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