mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-06 13:14:29 +08:00
Add unique experiment name and copy image when cloning
This commit is contained in:
parent
6e8e9ecf21
commit
2f6ccac3bc
2 changed files with 12 additions and 1 deletions
|
@ -308,8 +308,15 @@ class Experiment < ActiveRecord::Base
|
|||
|
||||
# Clone this experiment to given project
|
||||
def deep_clone_to_project(current_user, project)
|
||||
# First we have to find unique name for our little experiment
|
||||
experiment_names = project.experiments.map(&:name)
|
||||
new_name = name + " - clone "
|
||||
|
||||
i = 1
|
||||
i += 1 while experiment_names.include?(new_name + i.to_s)
|
||||
|
||||
clone = Experiment.new(
|
||||
name: name + rand(1..1000).to_s,
|
||||
name: new_name + i.to_s,
|
||||
description: description,
|
||||
created_by: current_user,
|
||||
last_modified_by: current_user,
|
||||
|
@ -327,6 +334,9 @@ class Experiment < ActiveRecord::Base
|
|||
end
|
||||
clone.save
|
||||
|
||||
# Create workflow image
|
||||
clone.delay.generate_workflow_img
|
||||
|
||||
clone
|
||||
end
|
||||
|
||||
|
|
|
@ -998,6 +998,7 @@ en:
|
|||
edit_asset_result: "<i>%{user}</i> edited file result <strong>%{result}</strong>."
|
||||
edit_text_result: "<i>%{user}</i> edited text result <strong>%{result}</strong>."
|
||||
edit_table_result: "<i>%{user}</i> edited table result <strong>%{result}</strong>."
|
||||
clone_experiment: "<i>%{user}</i> cloned <strong>%{experiment_new}</strong> from <strong>%{experiment_original}</strong>."
|
||||
|
||||
user_my_modules:
|
||||
new:
|
||||
|
|
Loading…
Add table
Reference in a new issue