scinote-web/app/services/repositories/restore_repository_service.rb
Alex Kriuchykhin 2a315ac106
Merge pull request #2681 from biosistemika/SCI-4780-replace-delete-button
SCI-4780 replace delete button with archive button
2020-06-24 13:16:11 +02:00

22 lines
563 B
Ruby

# frozen_string_literal: true
module Repositories
class RestoreRepositoryService < ArchiveRepositoryBaseService
def call
return self unless valid?
ActiveRecord::Base.transaction do
@repositories.each do |repository|
repository.restore!(@user)
log_activity(:restore_inventory, repository)
end
rescue ActiveRecord::RecordNotSaved
@errors[:restoring_error] = I18n.t('repositories.restore_inventories.unsuccess_flash')
raise ActiveRecord::Rollback
end
self
end
end
end