Skip to content

Commit

Permalink
Use edition links for worldwide organisation offices
Browse files Browse the repository at this point in the history
We are switching worldwide organisations to use edition links which do
not support multi-level link expanstion.

Therefore we need to switch the rendering code to use the new link
fields that have been added, in the absence of multi-level links.
  • Loading branch information
brucebolt committed Jan 22, 2024
1 parent e6a080a commit 8f692f4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions app/presenters/worldwide_organisation_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def people_in_non_primary_roles

def main_office
return unless (office_item = content_item.dig("links", "main_office")&.first)
return unless (office_contact_item = office_item.dig("links", "contact")&.first)

office_contact_item = contact_for_office(office_item["content_id"])
return unless office_contact_item

WorldwideOffice.new(
contact: WorldwideOrganisation::LinkedContactPresenter.new(office_contact_item),
Expand All @@ -93,7 +95,7 @@ def home_page_offices
return [] unless content_item.dig("links", "home_page_offices")

content_item.dig("links", "home_page_offices").map { |office|
next unless (contact = office.dig("links", "contact")&.first)
next unless (contact = contact_for_office(office["content_id"]))

WorldwideOrganisation::LinkedContactPresenter.new(contact)
}.compact
Expand Down Expand Up @@ -128,6 +130,18 @@ def sponsoring_organisations

private

def contact_for_office(office_content_id)
contact_mapping = content_item.dig("details", "office_contact_associations").select { |office_contact_association|
office_contact_association["office_content_id"] == office_content_id
}.first

return unless contact_mapping

content_item.dig("links", "contacts").select { |contact|
contact["content_id"] == contact_mapping["contact_content_id"]
}.first
end

def presented_title_for_roles(roles)
roles
.map { |role| role["title"] }
Expand Down

0 comments on commit 8f692f4

Please sign in to comment.