Merge pull request #9628 from tchak/fix-departement-epci

fix(epci): do not show let select departements with no epci
This commit is contained in:
Paul Chavard 2023-10-23 10:53:16 +00:00 committed by GitHub
commit 566b6b186e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 3 deletions

View file

@ -8,7 +8,7 @@ class EditableChamp::EpciComponent < EditableChamp::EditableChampBaseComponent
private private
def departement_options def departement_options
APIGeoService.departements.filter { _1[:code] != '99' }.map { ["#{_1[:code]} #{_1[:name]}", _1[:code]] } APIGeoService.departements.filter(&method(:departement_with_epci?)).map { ["#{_1[:code]} #{_1[:name]}", _1[:code]] }
end end
def epci_options def epci_options
@ -26,4 +26,9 @@ class EditableChamp::EpciComponent < EditableChamp::EditableChampBaseComponent
def epci_select_options def epci_select_options
{ selected: @champ.code }.merge(@champ.mandatory? ? { prompt: '' } : { include_blank: '' }) { selected: @champ.code }.merge(@champ.mandatory? ? { prompt: '' } : { include_blank: '' })
end end
def departement_with_epci?(departement)
code = departement[:code]
!code.start_with?('98') && !code.in?(['99', '975', '977', '978'])
end
end end

View file

@ -0,0 +1 @@
[]

View file

@ -0,0 +1 @@
[]

View file

@ -0,0 +1 @@
[]

View file

@ -0,0 +1 @@
[]

View file

@ -0,0 +1 @@
[]

View file

@ -10,8 +10,11 @@ namespace :api_geo_data do
departements = get_from_api_geo('departements?zone=metro,drom,com', 'departements') departements = get_from_api_geo('departements?zone=metro,drom,com', 'departements')
departements.each do |departement| departements.each do |departement|
departement_code = departement[:code] departement_code = departement[:code]
if !departement_code.start_with?('98') epci_filename = "epcis-#{departement_code}"
get_from_api_geo("epcis?codeDepartement=#{departement_code}", "epcis-#{departement_code}") if departement_code.start_with?('98')
PATH.join("#{epci_filename}.json").write(JSON.dump([]))
else
get_from_api_geo("epcis?codeDepartement=#{departement_code}", epci_filename)
end end
get_from_api_geo("communes?codeDepartement=#{departement_code}&type=commune-actuelle,arrondissement-municipal", "communes-#{departement_code}") get_from_api_geo("communes?codeDepartement=#{departement_code}&type=commune-actuelle,arrondissement-municipal", "communes-#{departement_code}")
end end