Skip to content

Commit

Permalink
Add "Verify LoPS" page
Browse files Browse the repository at this point in the history
This adds the views and controller actions to implement the new "Verify
LoPS" page according to the new designs of the verification journey.

Co-authored-by: Shujat Khalid <[email protected]>
  • Loading branch information
2 people authored and thomasleese committed Oct 13, 2023
1 parent fd6c765 commit c7a88f4
Show file tree
Hide file tree
Showing 18 changed files with 368 additions and 198 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module AssessorInterface
class ProfessionalStandingRequestsController < BaseController
before_action :set_variables

def show
authorize [:assessor_interface, professional_standing_request]
end

def edit_locate
authorize [:assessor_interface, professional_standing_request]

Expand Down Expand Up @@ -32,32 +36,27 @@ def update_locate
end
end

def edit_verify
authorize [:assessor_interface, professional_standing_request],
:edit_review?
def edit_request
authorize [:assessor_interface, professional_standing_request]

@form =
RequestableReviewForm.new(
requestable:,
user: current_staff,
passed: requestable.review_passed,
note: requestable.review_note,
)
@form = RequestableRequestForm.new(requestable:, user: current_staff)
end

def update_verify
authorize [:assessor_interface, professional_standing_request],
:update_review?
def update_request
authorize [:assessor_interface, professional_standing_request]

@form =
RequestableReviewForm.new(
review_form_params.merge(requestable:, user: current_staff),
RequestableRequestForm.new(
request_form_params.merge(user: current_staff, requestable:),
)

if @form.save
redirect_to [:assessor_interface, application_form]
else
render :edit_verify, status: :unprocessable_entity
redirect_to [
:assessor_interface,
application_form,
assessment,
:professional_standing_request,
]
end
end

Expand Down Expand Up @@ -93,6 +92,35 @@ def update_review
end
end

def edit_verify
authorize [:assessor_interface, professional_standing_request],
:edit_review?

@form =
RequestableReviewForm.new(
requestable:,
user: current_staff,
passed: requestable.review_passed,
note: requestable.review_note,
)
end

def update_verify
authorize [:assessor_interface, professional_standing_request],
:update_review?

@form =
RequestableReviewForm.new(
review_form_params.merge(requestable:, user: current_staff),
)

if @form.save
redirect_to [:assessor_interface, application_form]
else
render :edit_verify, status: :unprocessable_entity
end
end

private

def set_variables
Expand All @@ -107,9 +135,14 @@ def location_form_params
).permit(:received, :ready_for_review, :location_note)
end

def request_form_params
params.require(:assessor_interface_requestable_request_form).permit(
:passed,
)
end

def review_form_params
params.require(:assessor_interface_requestable_review_form).permit(
:reviewed,
:passed,
:note,
)
Expand Down
22 changes: 22 additions & 0 deletions app/forms/assessor_interface/requestable_request_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

class AssessorInterface::RequestableRequestForm
include ActiveModel::Model
include ActiveModel::Attributes

attr_accessor :requestable, :user, :application_form, :assessment
validates :requestable, :user, presence: true

attribute :passed, :boolean
validates :passed, inclusion: [true, false]

delegate :application_form, :assessment, to: :requestable

def save
return false if invalid?

RequestRequestable.call(requestable:, user:) if passed

true
end
end
11 changes: 8 additions & 3 deletions app/lib/application_form_status_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def received_lops
return false if teaching_authority_provides_written_statement

professional_standing_requests
.reject(&:reviewed?)
.reject(&:verified?)
.any? do |requestable|
requestable.received? || requestable.ready_for_review
end
Expand Down Expand Up @@ -312,19 +312,24 @@ def reference_requests
end

def overdue?(requestables:)
requestables.reject(&:reviewed?).any?(&:expired?)
requestables.reject(&:verified?).reject(&:reviewed?).any?(&:expired?)
end

def waiting_on?(requestables:)
requestables
.reject(&:verified?)
.reject(&:reviewed?)
.reject(&:expired?)
.reject(&:received?)
.any?(&:requested?)
end

def received?(requestables:)
requestables.reject(&:reviewed?).reject(&:expired?).any?(&:received?)
requestables
.reject(&:verified?)
.reject(&:reviewed?)
.reject(&:expired?)
.any?(&:received?)
end

def create_timeline_event(event_type:, **kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,20 +327,18 @@ def professional_standing_request_task_list_item
"assessor_interface.application_forms.show.assessment_tasks.items.professional_standing_request",
),
link: [
:locate,
:assessor_interface,
application_form,
assessment,
:professional_standing_request,
],
status:
if professional_standing_request.ready_for_review ||
professional_standing_request.received?
:completed
elsif professional_standing_request.expired?
:overdue
if professional_standing_request.verified?
"completed"
elsif professional_standing_request.requested?
"waiting_on"
else
:waiting_on
"not_started"
end,
}
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,14 @@
This screen is not an assessment of the letter of professional standing, it just confirms that a response has been received.
</p>

<% if @application_form.teaching_authority_provides_written_statement %>
<%= f.govuk_check_boxes_fieldset :received, multiple: false, legend: nil do %>
<%= f.govuk_check_box :received, true, false, multiple: false, link_errors: true,
label: { text: "The letter of professional standing has been received.", size: "s" } %>
<% end %>

<%= f.govuk_text_area :location_note, label: { text: "Where to find the response", size: "m" }, hint: nil %>
<% else %>
<%= f.govuk_radio_buttons_fieldset :received, legend: { size: "s" } do %>
<%= f.govuk_radio_button :received, :true, link_errors: true %>

<%= f.govuk_radio_button :received, :false, link_errors: true do %>
<%= f.govuk_collection_radio_buttons :ready_for_review, %i[true false], :itself, legend: { size: "s" } %>
<% end %>
<% end %>

<%= f.govuk_text_area :location_note, label: { size: "s" } %>
<%= f.govuk_check_boxes_fieldset :received, multiple: false, legend: nil do %>
<%= f.govuk_check_box :received, true, false, multiple: false, link_errors: true,
label: { text: "The letter of professional standing has been received.", size: "s" } %>
<% end %>

<%= f.govuk_submit "Save and continue" do %>
<%= f.govuk_text_area :location_note, label: { text: "Where to find the response", size: "m" }, hint: nil %>

<%= f.govuk_submit do %>
<%= govuk_link_to "Cancel", assessor_interface_application_form_path(@application_form) %>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<% title = "Request LoPS verification" %>

<% content_for :page_title, "#{"Error: " if @form.errors.any?}#{title}" %>
<% content_for :back_link_url, assessor_interface_application_form_path(@application_form) %>

<h1 class="govuk-heading-xl"><%= title %></h1>

<p class="govuk-body">To verify the applications LoPS you need to:</p>

<ul class="govuk-list govuk-list--bullet">
<li> go to the Zendesk and apply email macro 'PR Request LoPS verification'</li>
<li> add the applicant's details to the email</li>
<li> attach the LoPS to the email</li>
<li> find the relevant authority's and document their LoPS document</li>
<li> send the email to the relevant teaching authority</li>
</ul>

<p class="govuk-body">
Do you want to mark this task as completed and come back after you have sent the email from Zendesk?
</p>

<%= form_with model: @form, url: [:request, :assessor_interface, @application_form, @assessment, :professional_standing_request] do |f| %>
<%= f.govuk_radio_button :passed, :true, label: { text: "Yes, mark as completed" }, link_errors: true %>
<%= f.govuk_radio_button :passed, :false, label: { text: "No, come back later" } %>

<%= f.govuk_submit do %>
<%= govuk_link_to "Cancel", [:assessor_interface, @application_form, @assessment, :professional_standing_request] %>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<% content_for :page_title, "Verify LoPS" %>
<% content_for :back_link_url, assessor_interface_application_form_path(@application_form) %>

<h1 class="govuk-heading-xl">Verify LoPS</h1>

<p class="govuk-body">
You need to request verification for this applications LoPS. Follow the steps below:
</p>

<%= render(TaskList::Component.new(
[
{
title: "",
items: [
{
name: "Request LoPS verification",
link: unless @professional_standing_request.requested?
[
:request,
:assessor_interface,
@application_form,
@assessment,
:professional_standing_request,
]
end,
status: @professional_standing_request.requested? ? "completed" : "not_started"
},
{
name: "Record LoPS verification",
link: [
:review,
:assessor_interface,
@application_form,
@assessment,
:professional_standing_request
],
status: @professional_standing_request.status,
}
],
}
]
)) %>

<%= govuk_button_link_to "Back to overview", [:assessor_interface, @application_form] %>
4 changes: 4 additions & 0 deletions config/locales/assessor_interface.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ en:
blank: Enter why you selected ‘No’
failed:
inclusion: Select whether you want to mark this qualification as ‘Rejected’
assessor_interface/requestable_request_form:
attributes:
passed:
inclusion: Select whether you are satisfied that this is completed
assessor_interface/requestable_review_form:
attributes:
passed:
Expand Down
13 changes: 0 additions & 13 deletions config/locales/helpers.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ en:
text: Use the text box to add a note to the application history. Other assessors will be able to see any notes you add, but they will not be visible to the applicant.
assessor_interface_filter_form:
reference: "Example: 210245"
assessor_interface_professional_standing_request_location_form:
location_note: Use this space to add any useful notes, for example, where to locate the response.
assessor_interface_work_history_contact_form:
name: Type the updated full name in the text box below
job: Type the updated job title in the text box below
Expand Down Expand Up @@ -106,14 +104,6 @@ en:
location: Country trained in
name: Applicant name
reference: Application reference number
assessor_interface_professional_standing_request_location_form:
received_options:
true: "Yes"
false: "No"
ready_for_review_options:
true: "Yes, move to review"
false: "No, allow more time for a response"
location_note: Your notes (optional)
assessor_interface_qualification_request_form:
received_options:
true: "Yes"
Expand Down Expand Up @@ -286,9 +276,6 @@ en:
submitted_at: Created date
submitted_at_after: Start date
submitted_at_before: End date
assessor_interface_professional_standing_request_location_form:
received: Have you received a response about this letter of professional standing?
ready_for_review: Do you want to mark this for review?
assessor_interface_qualification_request_form:
received: Have you received a response about this qualification?
passed: Does the response show that the qualification is legitimate?
Expand Down
4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,12 @@

resource :professional_standing_request,
path: "/professional-standing-request",
only: [] do
only: [:show] do
member do
get "locate", to: "professional_standing_requests#edit_locate"
post "locate", to: "professional_standing_requests#update_locate"
get "request", to: "professional_standing_requests#edit_request"
post "request", to: "professional_standing_requests#update_request"
get "review", to: "professional_standing_requests#edit_review"
post "review", to: "professional_standing_requests#update_review"
get "verify", to: "professional_standing_requests#edit_verify"
Expand Down
6 changes: 6 additions & 0 deletions spec/factories/assessments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@
end

trait :with_professional_standing_request do
after(:create) do |assessment, _evaluator|
create(:professional_standing_request, assessment:)
end
end

trait :with_requested_professional_standing_request do
after(:create) do |assessment, _evaluator|
create(:professional_standing_request, :requested, assessment:)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module PageObjects
module AssessorInterface
class ProfessionalStandingRequest < SitePrism::Page
set_url "/assessor/applications/{application_form_id}/assessments/{assessment_id}" \
"/professional-standing-request"

section :task_list, TaskList, ".app-task-list"
element :status_tag, ".govuk-tag"

def request_lops_verification_task
task_list.find_item("Request LoPS verification")
end

def record_lops_verification_task
task_list.find_item("Record LoPS verification")
end
end
end
end
Loading

0 comments on commit c7a88f4

Please sign in to comment.