diff --git a/app/components/editable_champ/epci_component.rb b/app/components/editable_champ/epci_component.rb index b156c24aa..8bcf38437 100644 --- a/app/components/editable_champ/epci_component.rb +++ b/app/components/editable_champ/epci_component.rb @@ -8,7 +8,7 @@ class EditableChamp::EpciComponent < EditableChamp::EditableChampBaseComponent private 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 def epci_options @@ -26,4 +26,9 @@ class EditableChamp::EpciComponent < EditableChamp::EditableChampBaseComponent def epci_select_options { selected: @champ.code }.merge(@champ.mandatory? ? { prompt: '' } : { include_blank: '' }) end + + def departement_with_epci?(departement) + code = departement[:code] + !code.start_with?('98') && !code.in?(['99', '975', '977', '978']) + end end diff --git a/lib/data/api_geo/epcis-984.json b/lib/data/api_geo/epcis-984.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/lib/data/api_geo/epcis-984.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/lib/data/api_geo/epcis-986.json b/lib/data/api_geo/epcis-986.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/lib/data/api_geo/epcis-986.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/lib/data/api_geo/epcis-987.json b/lib/data/api_geo/epcis-987.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/lib/data/api_geo/epcis-987.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/lib/data/api_geo/epcis-988.json b/lib/data/api_geo/epcis-988.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/lib/data/api_geo/epcis-988.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/lib/data/api_geo/epcis-989.json b/lib/data/api_geo/epcis-989.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/lib/data/api_geo/epcis-989.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/lib/tasks/api_geo_data.rake b/lib/tasks/api_geo_data.rake index 1efd247af..eb7be15cd 100644 --- a/lib/tasks/api_geo_data.rake +++ b/lib/tasks/api_geo_data.rake @@ -10,8 +10,11 @@ namespace :api_geo_data do departements = get_from_api_geo('departements?zone=metro,drom,com', 'departements') departements.each do |departement| departement_code = departement[:code] - if !departement_code.start_with?('98') - get_from_api_geo("epcis?codeDepartement=#{departement_code}", "epcis-#{departement_code}") + epci_filename = "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 get_from_api_geo("communes?codeDepartement=#{departement_code}&type=commune-actuelle,arrondissement-municipal", "communes-#{departement_code}") end