diff --git a/app/models/territory.rb b/app/models/territory.rb index 98bf7e036d..6257b2159f 100644 --- a/app/models/territory.rb +++ b/app/models/territory.rb @@ -65,6 +65,9 @@ class Territory < ApplicationRecord where(id: Organisation.with_upcoming_rdvs.distinct.select(:territory_id)) } scope :ordered_by_name, -> { order(Arel.sql("unaccent(LOWER(territories.name))")) } + scope :with_phone_number_formatted, -> { where.not(phone_number_formatted: nil) } + scope :with_valid_department, -> { where(departement_number: DEPARTEMENTS_NAMES.keys) } + scope :with_invalid_department, -> { where.not(departement_number: DEPARTEMENTS_NAMES.keys) } ## - @@ -125,6 +128,10 @@ def waiting_room_enabled? end end + def department_name + DEPARTEMENTS_NAMES[departement_number] + end + private DEPARTEMENTS_NAMES = CSV.read(Rails.root.join("lib/assets/departements_fr.csv"), headers: :first_row) diff --git a/app/views/static_pages/contact.html.slim b/app/views/static_pages/contact.html.slim index 8a9dc1f5da..1e39426a14 100644 --- a/app/views/static_pages/contact.html.slim +++ b/app/views/static_pages/contact.html.slim @@ -1,7 +1,7 @@ - content_for :title, "Contact" -- Territory.where.not(phone_number_formatted: nil).order(:departement_number, :name).group_by(&:departement_number).each do |department_number, territories| - h2 #{department_number} +- Territory.with_phone_number_formatted.with_valid_department.order(:departement_number, :name).group_by(&:departement_number).each do |department_number, territories| + h2 #{department_number} - #{territories.first.department_name} ul.list-group.mb-2 - territories.each do |territory| li @@ -9,6 +9,11 @@ = link_to territory.phone_number, "tel:#{territory.phone_number_formatted}" h2 Autres contacts +ul.list-group.mb-2 + - Territory.with_phone_number_formatted.with_invalid_department.order(:name).each do |territory| + li + span> #{territory.name} + = link_to territory.phone_number, "tel:#{territory.phone_number_formatted}" span> Voir = link_to "l'annuaire des services publics", "https://lannuaire.service-public.fr/"