Skip to content

Commit

Permalink
Add department name and move invalid department in other category
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineGirard committed Oct 30, 2024
1 parent 708b700 commit 3459c9a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions app/models/territory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }

## -

Expand Down Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions app/views/static_pages/contact.html.slim
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
- 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
span> #{territory.name}
= 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/"

Expand Down

0 comments on commit 3459c9a

Please sign in to comment.