From d7332bb9229ff4f5560d126c05bff9835fdbdfed Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Fri, 6 Oct 2023 11:07:05 +0100 Subject: [PATCH] Add AssessmentRecommendationReviewController This adds a new controller for handling the process of sending the application to review after the verification stage. --- ...ssment_recommendation_review_controller.rb | 49 +++++++++++++++++++ .../edit.html.erb | 26 ++++++++++ config/routes.rb | 5 ++ 3 files changed, 80 insertions(+) create mode 100644 app/controllers/assessor_interface/assessment_recommendation_review_controller.rb create mode 100644 app/views/assessor_interface/assessment_recommendation_review/edit.html.erb diff --git a/app/controllers/assessor_interface/assessment_recommendation_review_controller.rb b/app/controllers/assessor_interface/assessment_recommendation_review_controller.rb new file mode 100644 index 0000000000..de2be07bdf --- /dev/null +++ b/app/controllers/assessor_interface/assessment_recommendation_review_controller.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +module AssessorInterface + class AssessmentRecommendationReviewController < BaseController + before_action :authorize_assessor + before_action :ensure_can_review + before_action :load_assessment_and_application_form + + def edit + @professional_standing_request = + assessment.professional_standing_request if assessment.professional_standing_request.verify_failed? + end + + def update + ActiveRecord::Base.transaction do + assessment.review! + ApplicationFormStatusUpdater.call( + application_form:, + user: current_staff, + ) + end + + redirect_to [:status, :assessor_interface, application_form] + end + + private + + def assessment + @assessment ||= + Assessment + .includes(:application_form) + .where(application_form_id: params[:application_form_id]) + .find(params[:assessment_id]) + end + + delegate :application_form, to: :assessment + + def ensure_can_review + unless assessment.can_review? + redirect_to [:assessor_interface, application_form] + end + end + + def load_assessment_and_application_form + @assessment = assessment + @application_form = application_form + end + end +end diff --git a/app/views/assessor_interface/assessment_recommendation_review/edit.html.erb b/app/views/assessor_interface/assessment_recommendation_review/edit.html.erb new file mode 100644 index 0000000000..b6a6de1219 --- /dev/null +++ b/app/views/assessor_interface/assessment_recommendation_review/edit.html.erb @@ -0,0 +1,26 @@ +<% content_for :page_title, "Send application for review" %> +<% content_for :back_link_url, assessor_interface_application_form_path(@application_form) %> + +

Send application for review

+ +

The following verification tasks have been flagged for review:

+ +<%= govuk_table do |table| + if @professional_standing_request.present? + table.with_caption(text: "LoPS") + table.with_head do |head| + head.with_row do |row| + row.with_cell(text: "Internal note") + row.with_cell(text: "Status") + end + end + table.with_body do |body| + body.with_row do |row| + row.with_cell { simple_format @professional_standing_request.verify_note } + row.with_cell { render(StatusTag::Component.new(@professional_standing_request.status)) } + end + end + end +end %> + +<%= govuk_button_to "Continue", [:assessor_interface, @application_form, @assessment, :assessment_recommendation_review], method: :put %> diff --git a/config/routes.rb b/config/routes.rb index 3e106f6e04..99e6aa39ce 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -64,6 +64,11 @@ post "confirm", to: "assessment_recommendation_decline#update_confirm" end + resource :assessment_recommendation_review, + controller: "assessment_recommendation_review", + path: "/recommendation/review", + only: %i[edit update] + resource :assessment_recommendation_verify, controller: "assessment_recommendation_verify", path: "/recommendation/verify",