From 9b7d321666ee21644e9b6f3e0d640b764fa2bc20 Mon Sep 17 00:00:00 2001 From: Mojca Lorber Date: Tue, 26 May 2020 15:34:20 +0200 Subject: [PATCH] Add rename task and rename experiment activities --- app/controllers/experiments_controller.rb | 6 +++++- app/controllers/my_modules_controller.rb | 2 ++ config/initializers/extends.rb | 3 ++- config/locales/global_activities/en.yml | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/controllers/experiments_controller.rb b/app/controllers/experiments_controller.rb index d228f4b9e..2f71a93a7 100644 --- a/app/controllers/experiments_controller.rb +++ b/app/controllers/experiments_controller.rb @@ -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 diff --git a/app/controllers/my_modules_controller.rb b/app/controllers/my_modules_controller.rb index 4221269eb..18ed2d66d 100644 --- a/app/controllers/my_modules_controller.rb +++ b/app/controllers/my_modules_controller.rb @@ -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 diff --git a/config/initializers/extends.rb b/config/initializers/extends.rb index 66bf08164..72733e6ca 100644 --- a/config/initializers/extends.rb +++ b/config/initializers/extends.rb @@ -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 = { diff --git a/config/locales/global_activities/en.yml b/config/locales/global_activities/en.yml index 251a5785f..ac5a1588c 100644 --- a/config/locales/global_activities/en.yml +++ b/config/locales/global_activities/en.yml @@ -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"