diff --git a/app/presenters/publishing_api/worldwide_organisation_presenter.rb b/app/presenters/publishing_api/worldwide_organisation_presenter.rb
index 2cff4e1b4ce..8411bae8f7b 100644
--- a/app/presenters/publishing_api/worldwide_organisation_presenter.rb
+++ b/app/presenters/publishing_api/worldwide_organisation_presenter.rb
@@ -30,7 +30,9 @@ def content
crest: "single-identity",
formatted_title: worldwide_organisation_logo_name(item),
},
+ office_contact_associations:,
ordered_corporate_information_pages:,
+ people_role_associations:,
secondary_corporate_information_pages:,
social_media_links:,
world_location_names:,
@@ -47,15 +49,17 @@ def content
def edition_links
{
+ contacts:,
corporate_information_pages:,
main_office:,
home_page_offices:,
primary_role_person:,
+ roles:,
+ role_appointments:,
secondary_role_person:,
office_staff:,
sponsoring_organisations:,
world_locations:,
- roles:,
}
end
@@ -91,6 +95,10 @@ def about_us
end
end
+ def contacts
+ [item.main_office&.contact&.content_id] + item.home_page_offices&.map(&:contact)&.map(&:content_id)
+ end
+
def main_office
return [] unless item.main_office
@@ -103,6 +111,17 @@ def home_page_offices
item.home_page_offices.map(&:content_id)
end
+ def office_contact_associations
+ offices = [item.main_office] + item.home_page_offices
+
+ offices.compact.map do |office|
+ {
+ office_content_id: office.content_id,
+ contact_content_id: office.contact.content_id,
+ }
+ end
+ end
+
def primary_role_person
return [] unless item.primary_role
@@ -119,10 +138,29 @@ def office_staff
item.office_staff_roles.map(&:current_person).map(&:content_id)
end
+ def role_appointments
+ item.roles&.distinct&.map(&:current_role_appointment)&.compact&.map(&:content_id)
+ end
+
def roles
item.roles.distinct.pluck(:content_id)
end
+ def people_role_associations
+ people = [item.primary_role&.current_person] + [item.secondary_role&.current_person] + item.office_staff_roles.map(&:current_person)
+ people.compact.map do |person|
+ {
+ person_content_id: person.content_id,
+ role_appointments: person.role_appointments&.map do |role_appointment|
+ {
+ role_appointment_content_id: role_appointment.content_id,
+ role_content_id: role_appointment.role.content_id,
+ }
+ end,
+ }
+ end
+ end
+
def corporate_information_pages
return [] unless item.corporate_information_pages.any?
diff --git a/test/unit/app/presenters/publishing_api/worldwide_organisation_presenter_test.rb b/test/unit/app/presenters/publishing_api/worldwide_organisation_presenter_test.rb
index e83013842f6..d70a13f9f89 100644
--- a/test/unit/app/presenters/publishing_api/worldwide_organisation_presenter_test.rb
+++ b/test/unit/app/presenters/publishing_api/worldwide_organisation_presenter_test.rb
@@ -45,6 +45,12 @@ def present(...)
crest: "single-identity",
formatted_title: "Locationia
Embassy",
},
+ office_contact_associations: [
+ {
+ office_content_id: worldwide_org.reload.offices.first.content_id,
+ contact_content_id: worldwide_org.reload.offices.first.contact.content_id,
+ },
+ ],
ordered_corporate_information_pages: [
{
content_id: worldwide_org.corporate_information_pages[1].content_id,
@@ -55,6 +61,26 @@ def present(...)
title: "Working for Locationia Embassy",
},
],
+ people_role_associations: [
+ {
+ person_content_id: ambassador.content_id,
+ role_appointments: [
+ {
+ role_appointment_content_id: ambassador.roles.first.current_role_appointment.content_id,
+ role_content_id: ambassador.roles.first.current_role_appointment.role.content_id,
+ },
+ ],
+ },
+ {
+ person_content_id: deputy_head_of_mission.content_id,
+ role_appointments: [
+ {
+ role_appointment_content_id: deputy_head_of_mission.roles.first.current_role_appointment.content_id,
+ role_content_id: deputy_head_of_mission.roles.first.current_role_appointment.role.content_id,
+ },
+ ],
+ },
+ ],
secondary_corporate_information_pages: "Read about the types of information we routinely publish in our Publication scheme. Find out about our commitment to publishing in Welsh. Our Personal information charter explains how we treat your personal information.",
social_media_links: [
{
@@ -71,6 +97,9 @@ def present(...)
],
},
links: {
+ contacts: [
+ worldwide_org.reload.offices.first.contact.content_id,
+ ],
corporate_information_pages: [
worldwide_org.corporate_information_pages[0].content_id,
worldwide_org.corporate_information_pages[1].content_id,
@@ -99,6 +128,9 @@ def present(...)
roles: [
ambassador.roles.first.content_id, deputy_head_of_mission.roles.first.content_id
],
+ role_appointments: [
+ ambassador.roles.first.current_role_appointment.content_id, deputy_head_of_mission.roles.first.current_role_appointment.content_id
+ ],
},
analytics_identifier: "WO123",
update_type: "major",