From db01c8f6f762918479fdad6d35b19fc79a604b50 Mon Sep 17 00:00:00 2001 From: Leonidas Apostolidis Date: Wed, 5 Jun 2024 13:29:44 +0100 Subject: [PATCH] Show challenged reason if partnership exists and has been challenged To provide more context to super users why the partnership can't be created. --- .../change_relationship_wizard.rb | 12 ++++++++++++ .../relationship_already_exists.html.erb | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/app/forms/admin/participants/change_relationship/change_relationship_wizard.rb b/app/forms/admin/participants/change_relationship/change_relationship_wizard.rb index 4fd1ca73bd..87b9b2ffe7 100644 --- a/app/forms/admin/participants/change_relationship/change_relationship_wizard.rb +++ b/app/forms/admin/participants/change_relationship/change_relationship_wizard.rb @@ -109,6 +109,18 @@ def create_relationship! end end + def existing_partnership + @existing_partnership = Partnership.find_by(cohort:, school:, lead_provider_id:, delivery_partner_id:) + end + + def existing_partnership_challenged_at + existing_partnership.challenged_at.to_formatted_s(:govuk) + end + + def existing_partnership_challenge_reason + existing_partnership.challenge_reason.humanize + end + def selected_lead_provider_name selected_lead_provider&.name end diff --git a/app/views/admin/participants/change_relationship/relationship_already_exists.html.erb b/app/views/admin/participants/change_relationship/relationship_already_exists.html.erb index 7da4d0d1a8..407ec676c5 100644 --- a/app/views/admin/participants/change_relationship/relationship_already_exists.html.erb +++ b/app/views/admin/participants/change_relationship/relationship_already_exists.html.erb @@ -17,6 +17,16 @@ <% row.with_key { "Delivery partner" } %> <% row.with_value { @wizard.selected_delivery_partner_name } %> <% end %> + <% if @wizard.existing_partnership.challenged_at %> + <% summary_list.with_row do |row| %> + <% row.with_key { "Challenged at" } %> + <% row.with_value { @wizard.existing_partnership_challenged_at } %> + <% end %> + <% summary_list.with_row do |row| %> + <% row.with_key { "Challenge reason" } %> + <% row.with_value { @wizard.existing_partnership_challenge_reason } %> + <% end %> + <% end %> <% end %> <%= govuk_link_to "Return to change relationship", @wizard.show_path_for(step: :change_training_programme), no_visited_state: true %>