From caa31095c3df9210c22126ed0bf09ff4668b1ce3 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Fri, 24 Nov 2023 15:21:39 +0000 Subject: [PATCH] Show awarded and declined personas The new stage field combined them in to a single "completed" stage, but we want to split these out so we can choose between awarded and declined personas. --- app/controllers/personas_controller.rb | 23 +++++++++++++++++------ app/views/personas/index.html.erb | 4 ++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/controllers/personas_controller.rb b/app/controllers/personas_controller.rb index aa07e91d70..1eb67958ea 100644 --- a/app/controllers/personas_controller.rb +++ b/app/controllers/personas_controller.rb @@ -117,10 +117,10 @@ def load_eligible_personas %w[online written none] .product( %w[online written none], - %w[draft not_started verification completed], + %w[draft not_started verification awarded declined], ) - .map do |status_check, sanction_check, stage| - { status_check:, sanction_check:, stage: } + .map do |status_check, sanction_check, stage_or_status| + { status_check:, sanction_check:, stage_or_status: } end def load_teacher_personas @@ -141,9 +141,20 @@ def load_teacher_personas all_application_forms.find do |application_form| region = application_form.region - region.status_check == persona[:status_check] && - region.sanction_check == persona[:sanction_check] && - application_form.stage == persona[:stage] + unless region.status_check == persona[:status_check] && + region.sanction_check == persona[:sanction_check] + next + end + + stage_or_status = persona[:stage_or_status] + + if stage_or_status == "awarded" + application_form.awarded_at.present? + elsif stage_or_status == "declined" + application_form.declined_at.present? + else + application_form.stage == stage_or_status + end end if (application_form = found_application_form) diff --git a/app/views/personas/index.html.erb b/app/views/personas/index.html.erb index 626ca92dc8..b2b12ad7b4 100644 --- a/app/views/personas/index.html.erb +++ b/app/views/personas/index.html.erb @@ -125,7 +125,7 @@ row.with_cell(header: true, text: "Country") row.with_cell(header: true, text: "Status check") row.with_cell(header: true, text: "Sanction check") - row.with_cell(header: true, text: "Stage") + row.with_cell(header: true, text: "Stage/status") row.with_cell(header: true, text: "Email address") row.with_cell(header: true, text: "Actions", numeric: true) end @@ -143,7 +143,7 @@ row.with_cell { persona_check_tag(persona[:status_check]) } row.with_cell { persona_check_tag(persona[:sanction_check]) } row.with_cell do - render(StatusTag::Component.new(persona[:stage])) + render(StatusTag::Component.new(persona[:stage_or_status])) end row.with_cell { persona[:teacher].email }