refactor: commune_champ

This commit is contained in:
simon lehericey 2024-04-10 11:08:25 +02:00
parent c77b66feef
commit 124433b781
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5

View file

@ -57,20 +57,11 @@ class Champs::CommuneChamp < Champs::TextChamp
alias postal_code code_postal
def name
if departement? && code?
APIGeoService.commune_name(code_departement, code).presence || safe_to_s
else
safe_to_s
end
APIGeoService.safely_normalize_city_name(code_departement, code, safe_to_s)
end
def to_s
if departement? && code_postal? && code?
name = APIGeoService.commune_name(code_departement, code)
name.present? ? "#{name} (#{code_postal})" : safe_to_s
else
safe_to_s
end
code_postal? ? "#{name} (#{code_postal})" : name
end
def code