fix(address): BAN does not return postcode for some TOM like Nouvelle-Calédonie
But we have to fallback to an empty string because API graphql / serializer expects a non-null attribute.
This commit is contained in:
parent
7a80574afc
commit
db65c9178e
4 changed files with 37 additions and 4 deletions
|
@ -97,9 +97,13 @@ class Champs::AddressChamp < Champs::TextChamp
|
|||
end
|
||||
|
||||
def commune_name
|
||||
if full_address?
|
||||
"#{APIGeoService.commune_name(code_departement, address['city_code'])} (#{address['postal_code']})"
|
||||
end
|
||||
return if !full_address?
|
||||
|
||||
commune = APIGeoService.commune_name(code_departement, address['city_code'])
|
||||
|
||||
return commune if address['postal_code'].blank?
|
||||
|
||||
"#{commune} (#{address['postal_code']})"
|
||||
end
|
||||
|
||||
def commune
|
||||
|
|
|
@ -115,7 +115,7 @@ class APIGeoService
|
|||
label: properties.fetch('label'),
|
||||
type: properties.fetch('type'),
|
||||
street_address: properties.fetch('name'),
|
||||
postal_code: properties.fetch('postcode'),
|
||||
postal_code: properties.fetch('postcode') { '' }, # API graphql / serializer requires non-null data
|
||||
street_number: properties['housenumber'],
|
||||
street_name: properties['street'],
|
||||
geometry: feature['geometry']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue