Merge pull request #10749 from mfo/US/commune-without-insee
correctif: ETQ administrateur/instructeur, je souhaite que les champs de type commune aient tjr un code insee afin de router de maniere fiable
This commit is contained in:
commit
915779c9b0
10 changed files with 305 additions and 68 deletions
|
@ -4,6 +4,9 @@ class Champs::CommuneChamp < Champs::TextChamp
|
|||
store_accessor :value_json, :code_departement, :code_postal, :code_region
|
||||
before_save :on_codes_change, if: :should_refresh_after_code_change?
|
||||
|
||||
validates :external_id, presence: true, if: -> { validate_champ_value_or_prefill? && value.present? }
|
||||
after_validation :instrument_external_id_error, if: -> { errors.include?(:external_id) }
|
||||
|
||||
def departement_name
|
||||
APIGeoService.departement_name(code_departement)
|
||||
end
|
||||
|
@ -101,4 +104,11 @@ class Champs::CommuneChamp < Champs::TextChamp
|
|||
def should_refresh_after_code_change?
|
||||
!departement? || code_postal_changed? || external_id_changed?
|
||||
end
|
||||
|
||||
def instrument_external_id_error
|
||||
Sentry.capture_message(
|
||||
"Commune with value and no external id Edge case reached",
|
||||
extra: { request_id: Current.request_id }
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue