mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-10 17:36:33 +08:00
Merge pull request #4192 from aignatov-bio/ai-sci-6928-add-activities-to-bulk-step-deleteting
Add activity to bulk step deletion [SCI-6928]
This commit is contained in:
commit
ef71e59c4d
1 changed files with 14 additions and 2 deletions
|
@ -259,17 +259,29 @@ class ProtocolsController < ApplicationController
|
|||
end
|
||||
|
||||
def delete_steps
|
||||
@protocol.my_module.lock!
|
||||
|
||||
Protocol.transaction do
|
||||
team = @protocol.team
|
||||
previous_size = 0
|
||||
|
||||
@protocol.steps.each do |step|
|
||||
previous_size += step.space_taken
|
||||
|
||||
if @protocol.in_module?
|
||||
log_activity(:destroy_step, @protocol.my_module.experiment.project,
|
||||
my_module: @protocol.my_module.id,
|
||||
step: step.id,
|
||||
step_position: { id: step.id, value_for: 'position_plus_one' })
|
||||
else
|
||||
log_activity(:delete_step_in_protocol_repository, nil, step: step.id,
|
||||
step_position: { id: step.id, value_for: 'position_plus_one' })
|
||||
end
|
||||
|
||||
step.destroy!
|
||||
end
|
||||
|
||||
team.release_space(previous_size)
|
||||
team.save
|
||||
team.save!
|
||||
render json: { status: 'ok' }
|
||||
rescue ActiveRecord::RecordNotDestroyed
|
||||
render json: { status: 'error' }, status: :unprocessable_entity
|
||||
|
|
Loading…
Reference in a new issue