From 448553a4b40af29c9d58c8b92bfadcd157d9c267 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Thu, 5 Oct 2023 13:43:08 +0100 Subject: [PATCH] Allow admins to respond to LoPS This ensures that admins are marked as the action required by user type when the LoPS has been marked as received, or is overdue. --- app/lib/application_form_status_updater.rb | 32 +++++++++++++------ .../application_form_status_updater_spec.rb | 2 +- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/app/lib/application_form_status_updater.rb b/app/lib/application_form_status_updater.rb index 943a8de542..84092500c8 100644 --- a/app/lib/application_form_status_updater.rb +++ b/app/lib/application_form_status_updater.rb @@ -180,14 +180,14 @@ def action_required_by application_form.declined_at.present? || application_form.awarded_at.present? "none" - elsif preliminary_check? - "admin" elsif dqt_trn_request.present? || assessment_in_review? || - overdue_further_information || overdue_lops || - overdue_qualification || overdue_reference || - received_further_information || received_lops || + overdue_further_information || overdue_qualification || + overdue_reference || received_further_information || received_qualification || received_reference "assessor" + elsif preliminary_check? || need_to_request_lops? || overdue_lops || + received_lops + "admin" elsif waiting_on_further_information || waiting_on_lops || waiting_on_qualification || waiting_on_reference "external" @@ -209,10 +209,10 @@ def stage elsif preliminary_check? || (teaching_authority_provides_written_statement && waiting_on_lops) "pre_assessment" - elsif assessment_in_verify? || overdue_lops || overdue_qualification || - overdue_reference || received_lops || received_qualification || - received_reference || waiting_on_lops || waiting_on_qualification || - waiting_on_reference + elsif assessment_in_verify? || need_to_request_lops? || overdue_lops || + overdue_qualification || overdue_reference || received_lops || + received_qualification || received_reference || waiting_on_lops || + waiting_on_qualification || waiting_on_reference "verification" elsif overdue_further_information || received_further_information || waiting_on_further_information || @@ -247,7 +247,11 @@ def statuses elsif requestable_statuses.present? requestable_statuses elsif assessment_in_verify? - %w[verification_in_progress] + if need_to_request_lops? + %w[verification_not_started] + else + %w[verification_in_progress] + end elsif assessment.any_not_preliminary_section_finished? %w[assessment_in_progress] else @@ -284,6 +288,14 @@ def assessment_in_verify? assessment&.verify? || false end + def need_to_request_lops? + return false if teaching_authority_provides_written_statement + + professional_standing_requests.any? do |requestable| + !requestable.requested? + end + end + def requestable_statuses @requestable_statuses ||= %w[overdue received waiting_on] diff --git a/spec/lib/application_form_status_updater_spec.rb b/spec/lib/application_form_status_updater_spec.rb index 33238d80cf..e833bf2124 100644 --- a/spec/lib/application_form_status_updater_spec.rb +++ b/spec/lib/application_form_status_updater_spec.rb @@ -240,7 +240,7 @@ create(:professional_standing_request, :received, assessment:) end - include_examples "changes action required by", "assessor" + include_examples "changes action required by", "admin" include_examples "changes stage", "verification" include_examples "changes statuses", %w[received_lops] include_examples "changes status", "received"