Remove skip_cleanup option
This commit is contained in:
parent
bcdc9c18ae
commit
2e8c0512a5
3 changed files with 3 additions and 10 deletions
|
@ -7,10 +7,10 @@ class Champs::RNAController < ApplicationController
|
|||
@network_error = false
|
||||
begin
|
||||
data = APIEntreprise::RNAAdapter.new(@rna, @champ.procedure_id).to_params
|
||||
@champ.update!(data: data, value: @rna, skip_cleanup: true)
|
||||
@champ.update!(data: data, value: @rna)
|
||||
rescue APIEntreprise::API::Error, ActiveRecord::RecordInvalid => error
|
||||
@network_error = true if error.try(:network_error?) && !APIEntrepriseService.api_up?
|
||||
@champ.update(data: nil, value: nil, skip_cleanup: true)
|
||||
@champ.update(data: nil, value: nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,8 +25,6 @@ class Champ < ApplicationRecord
|
|||
belongs_to :parent, class_name: 'Champ', optional: true
|
||||
has_one_attached :piece_justificative_file
|
||||
|
||||
attr_accessor :skip_cleanup
|
||||
|
||||
# We declare champ specific relationships (Champs::CarteChamp, Champs::SiretChamp and Champs::RepetitionChamp)
|
||||
# here because otherwise we can't easily use includes in our queries.
|
||||
has_many :geo_areas, -> { order(:created_at) }, dependent: :destroy, inverse_of: :champ
|
||||
|
@ -79,7 +77,7 @@ class Champ < ApplicationRecord
|
|||
|
||||
before_create :set_dossier_id, if: :needs_dossier_id?
|
||||
before_validation :set_dossier_id, if: :needs_dossier_id?
|
||||
before_save :cleanup_if_empty, unless: :skip_cleanup
|
||||
before_save :cleanup_if_empty
|
||||
before_save :normalize
|
||||
after_update_commit :fetch_external_data_later
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ class Champs::RNAChamp < Champ
|
|||
validates :value, allow_blank: true, format: {
|
||||
with: /\AW[0-9]{9}\z/, message: I18n.t(:not_a_rna, scope: 'activerecord.errors.messages')
|
||||
}
|
||||
after_validation :update_external_id, if: -> { value_changed? }
|
||||
|
||||
delegate :id, to: :procedure, prefix: true
|
||||
|
||||
|
@ -42,8 +41,4 @@ class Champs::RNAChamp < Champ
|
|||
def search_terms
|
||||
etablissement.present? ? etablissement.search_terms : [value]
|
||||
end
|
||||
|
||||
def update_external_id
|
||||
self.external_id = self.value
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue