Add rename task and rename experiment activities

This commit is contained in:
Mojca Lorber 2020-05-26 15:34:20 +02:00
parent 4b7b3a8622
commit 9b7d321666
4 changed files with 11 additions and 2 deletions

View file

@ -91,14 +91,18 @@ class ExperimentsController < ApplicationController
end
old_text = @experiment.description
@experiment.update(experiment_params)
@experiment.assign_attributes(experiment_params)
@experiment.last_modified_by = current_user
name_changed = @experiment.name_changed?
description_changed = @experiment.description_changed?
if @experiment.save
experiment_annotation_notification(old_text) if old_text
activity_type = if experiment_params[:archived] == 'false'
:restore_experiment
elsif name_changed && !description_changed
:rename_experiment
else
:edit_experiment
end

View file

@ -145,6 +145,7 @@ class MyModulesController < ApplicationController
def update
@my_module.assign_attributes(my_module_params)
@my_module.last_modified_by = current_user
name_changed = @my_module.name_changed?
description_changed = @my_module.description_changed?
start_date_changes = @my_module.changes[:started_on]
due_date_changes = @my_module.changes[:due_date]
@ -165,6 +166,7 @@ class MyModulesController < ApplicationController
TinyMceAsset.update_images(@my_module, params[:tiny_mce_images], current_user)
end
log_activity(:rename_task) if name_changed
log_start_date_change_activity(start_date_changes) if start_date_changes.present?
log_due_date_change_activity(due_date_changes) if due_date_changes.present?
end

View file

@ -282,7 +282,8 @@ class Extends
protocol_description_in_task_edited: 137,
set_task_start_date: 138,
change_task_start_date: 139,
remove_task_start_date: 140
remove_task_start_date: 140,
rename_experiment: 141
}
ACTIVITY_GROUPS = {

View file

@ -86,6 +86,7 @@ en:
assign_user_to_module_html: "%{user} assigned user %{user_target} to task %{my_module}."
unassign_user_from_module_html: "%{user} removed user %{user_target} from task %{my_module}."
create_experiment_html: "%{user} created experiment %{experiment}."
rename_experiment_html: "%{user} renamed experiment %{experiment}."
edit_experiment_html: "%{user} edited experiment %{experiment}."
move_experiment_html: "%{user} moved experiment %{experiment} from project %{project_original} to project %{project_new}."
clone_experiment_html: "%{user} copied experiment %{experiment_new} from experiment %{experiment_original} as template."
@ -219,6 +220,7 @@ en:
assign_user_to_module: "User assigned to Task"
unassign_user_from_module: "User removed from Task"
create_experiment: "Experiment created"
rename_experiment: "Experiment renamed"
edit_experiment: "Experiment edited"
move_experiment: "Experiment moved"
clone_experiment: "Experiment copied as template"