From 61d1f5374db398d41b93d863c4eb30b4cd050692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Zrim=C5=A1ek?= Date: Sun, 4 Mar 2018 15:24:43 +0100 Subject: [PATCH] Additionaly removed some unneeded code, related to the previous commit. --- app/controllers/step_comments_controller.rb | 78 ++++++++++----------- 1 file changed, 36 insertions(+), 42 deletions(-) diff --git a/app/controllers/step_comments_controller.rb b/app/controllers/step_comments_controller.rb index 259fbc88a..713592122 100644 --- a/app/controllers/step_comments_controller.rb +++ b/app/controllers/step_comments_controller.rb @@ -51,21 +51,19 @@ class StepCommentsController < ApplicationController step_comment_annotation_notification # Generate activity (this can only occur in module, # but nonetheless check if my module is not nil) - if @protocol.in_module? - Activity.create( - type_of: :add_comment_to_step, - user: current_user, - project: @step.my_module.experiment.project, - experiment: @step.my_module.experiment, - my_module: @step.my_module, - message: t( - "activities.add_comment_to_step", - user: current_user.full_name, - step: @step.position + 1, - step_name: @step.name - ) + Activity.create( + type_of: :add_comment_to_step, + user: current_user, + project: @step.my_module.experiment.project, + experiment: @step.my_module.experiment, + my_module: @step.my_module, + message: t( + "activities.add_comment_to_step", + user: current_user.full_name, + step: @step.position + 1, + step_name: @step.name ) - end + ) format.json { render json: { @@ -112,21 +110,19 @@ class StepCommentsController < ApplicationController step_comment_annotation_notification(old_text) # Generate activity - if @protocol.in_module? - Activity.create( - type_of: :edit_step_comment, - user: current_user, - project: @step.my_module.experiment.project, - experiment: @step.my_module.experiment, - my_module: @step.my_module, - message: t( - 'activities.edit_step_comment', - user: current_user.full_name, - step: @step.position + 1, - step_name: @step.name - ) + Activity.create( + type_of: :edit_step_comment, + user: current_user, + project: @step.my_module.experiment.project, + experiment: @step.my_module.experiment, + my_module: @step.my_module, + message: t( + 'activities.edit_step_comment', + user: current_user.full_name, + step: @step.position + 1, + step_name: @step.name ) - end + ) message = custom_auto_link(@comment.message) render json: { comment: message }, status: :ok else @@ -142,21 +138,19 @@ class StepCommentsController < ApplicationController format.json do if @comment.destroy # Generate activity - if @protocol.in_module? - Activity.create( - type_of: :delete_step_comment, - user: current_user, - project: @step.my_module.experiment.project, - experiment: @step.my_module.experiment, - my_module: @step.my_module, - message: t( - 'activities.delete_step_comment', - user: current_user.full_name, - step: @step.position + 1, - step_name: @step.name - ) + Activity.create( + type_of: :delete_step_comment, + user: current_user, + project: @step.my_module.experiment.project, + experiment: @step.my_module.experiment, + my_module: @step.my_module, + message: t( + 'activities.delete_step_comment', + user: current_user.full_name, + step: @step.position + 1, + step_name: @step.name ) - end + ) render json: {}, status: :ok else render json: { message: I18n.t('comments.delete_error') },