Skip to content

Commit

Permalink
Merge pull request #1722 from DFE-Digital/verification-lops
Browse files Browse the repository at this point in the history
LoPS verification journey
  • Loading branch information
thomasleese authored Nov 8, 2023
2 parents e17fe84 + 59ae8b7 commit c5b6905
Show file tree
Hide file tree
Showing 66 changed files with 1,006 additions and 549 deletions.
7 changes: 7 additions & 0 deletions app/assets/stylesheets/_task_list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
}
}

.app-task-list__items-no-indentation {
@include govuk-font($size: 19);
@include govuk-responsive-margin(9, "bottom");
list-style: none;
padding-left: 0;
}

.app-task-list__items {
@include govuk-font($size: 19);
@include govuk-responsive-margin(9, "bottom");
Expand Down
5 changes: 5 additions & 0 deletions app/assets/stylesheets/application.sass.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,8 @@ ul.autocomplete__menu {
.govuk-inset-text .govuk-details {
margin-bottom: 0;
}

.app-table__center {
text-align: center;
vertical-align: middle;
}
2 changes: 1 addition & 1 deletion app/components/status_tag/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def tags
received_reference: "purple",
rejected: "red",
requested: "yellow",
review: "purple",
review: "pink",
submitted: "grey",
valid: "green",
verification: "yellow",
Expand Down
2 changes: 1 addition & 1 deletion app/components/task_list/component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<%= section[:title] %>
</h2>

<ul class="app-task-list__items">
<ul class="<%= section[:title].present? ? 'app-task-list__items' : 'app-task-list__items-no-indentation' %>">
<% section[:items].each do |item| %>
<li class="app-task-list__item">
<% status_id = "#{section[:number]}-#{section[:key]}-#{item[:key]}-status" %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@

module AssessorInterface
class AssessmentRecommendationReviewController < BaseController
before_action :authorize_assessor
before_action :ensure_can_review
before_action :load_assessment_and_application_form

def edit
authorize %i[assessor_interface assessment_recommendation]

@professional_standing_request =
assessment.professional_standing_request if assessment.professional_standing_request.verify_failed?

render layout: "full_from_desktop"
end

def update
authorize %i[assessor_interface assessment_recommendation]

ActiveRecord::Base.transaction do
assessment.review!
ApplicationFormStatusUpdater.call(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def update_verify_qualifications
if @form.verify_qualifications
:qualification_requests
else
:verify_professional_standing
:professional_standing
end
),
:assessor_interface,
Expand Down Expand Up @@ -121,7 +121,7 @@ def email_consent_letters
application_form.qualifications.where(id: session[:qualification_ids])
end

def edit_verify_professional_standing
def edit_professional_standing
authorize %i[assessor_interface assessment_recommendation], :edit?

if application_form.teaching_authority_provides_written_statement
Expand All @@ -138,7 +138,7 @@ def edit_verify_professional_standing
@form = VerifyProfessionalStandingForm.new
end

def update_verify_professional_standing
def update_professional_standing
authorize %i[assessor_interface assessment_recommendation], :update?

@form =
Expand All @@ -154,27 +154,17 @@ def update_verify_professional_standing
session[:professional_standing] = @form.verify_professional_standing

redirect_to [
(
if @form.verify_professional_standing
:contact_professional_standing
else
:reference_requests
end
),
:reference_requests,
:assessor_interface,
application_form,
assessment,
:assessment_recommendation_verify,
]
else
render :edit_verify_professional_standing, status: :unprocessable_entity
render :edit_professional_standing, status: :unprocessable_entity
end
end

def contact_professional_standing
authorize %i[assessor_interface assessment_recommendation], :edit?
end

def edit_reference_requests
authorize %i[assessor_interface assessment_recommendation], :edit?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ module AssessorInterface
class ProfessionalStandingRequestsController < BaseController
before_action :set_variables

def edit_locate
before_action do
authorize [:assessor_interface, professional_standing_request]
end

def show
render layout: "full_from_desktop"
end

def edit_locate
@form =
ProfessionalStandingRequestLocationForm.new(
requestable:,
Expand All @@ -18,8 +24,6 @@ def edit_locate
end

def update_locate
authorize [:assessor_interface, professional_standing_request]

@form =
ProfessionalStandingRequestLocationForm.new(
location_form_params.merge(requestable:, user: current_staff),
Expand All @@ -28,42 +32,42 @@ def update_locate
if @form.save
redirect_to [:assessor_interface, application_form]
else
render :edit_location, status: :unprocessable_entity
render :edit_locate, status: :unprocessable_entity
end
end

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

def edit_request
@form =
RequestableReviewForm.new(
RequestableRequestForm.new(
requestable:,
user: current_staff,
passed: requestable.review_passed,
note: requestable.review_note,
passed: professional_standing_request.requested?,
)
end

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

def update_request
@form =
RequestableReviewForm.new(
review_form_params.merge(requestable:, user: current_staff),
RequestableRequestForm.new(
requestable:,
user: current_staff,
passed:
params.dig(:assessor_interface_requestable_request_form, :passed) ||
false,
)

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

def edit_review
authorize [:assessor_interface, professional_standing_request]

@form =
RequestableReviewForm.new(
requestable:,
Expand All @@ -74,8 +78,6 @@ def edit_review
end

def update_review
authorize [:assessor_interface, professional_standing_request]

@form =
RequestableReviewForm.new(
review_form_params.merge(requestable:, user: current_staff),
Expand All @@ -93,6 +95,70 @@ def update_review
end
end

def edit_verify
@form =
RequestableVerifyPassedForm.new(
requestable:,
user: current_staff,
passed: requestable.verify_passed,
)
end

def update_verify
@form =
RequestableVerifyPassedForm.new(
verify_passed_form_params.merge(requestable:, user: current_staff),
)

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

def edit_verify_failed
@form =
RequestableVerifyFailedForm.new(
requestable:,
user: current_staff,
note: requestable.verify_note,
)
end

def update_verify_failed
@form =
RequestableVerifyFailedForm.new(
verify_failed_form_params.merge(requestable:, user: current_staff),
)

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

private

def set_variables
Expand All @@ -109,12 +175,23 @@ def location_form_params

def review_form_params
params.require(:assessor_interface_requestable_review_form).permit(
:reviewed,
:passed,
:note,
)
end

def verify_passed_form_params
params.require(:assessor_interface_requestable_verify_passed_form).permit(
:passed,
)
end

def verify_failed_form_params
params.require(:assessor_interface_requestable_verify_failed_form).permit(
:note,
)
end

def professional_standing_request
@professional_standing_request ||=
ProfessionalStandingRequest.joins(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ def index

@professional_standing_request =
assessment.professional_standing_request if assessment.professional_standing_request.verify_failed?

render layout: "full_from_desktop"
end

private
Expand Down
24 changes: 24 additions & 0 deletions app/forms/assessor_interface/requestable_request_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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?

if passed && !requestable.requested?
RequestRequestable.call(requestable:, user:)
end

true
end
end
20 changes: 20 additions & 0 deletions app/forms/assessor_interface/requestable_verify_failed_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

class AssessorInterface::RequestableVerifyFailedForm
include ActiveModel::Model
include ActiveModel::Attributes

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

attribute :note, :string
validates :note, presence: true

def save
return false if invalid?

VerifyRequestable.call(requestable:, user:, passed: false, note:)

true
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class AssessorInterface::RequestableVerifyForm
class AssessorInterface::RequestableVerifyPassedForm
include ActiveModel::Model
include ActiveModel::Attributes

Expand All @@ -10,13 +10,12 @@ class AssessorInterface::RequestableVerifyForm
attribute :passed, :boolean
validates :passed, inclusion: [true, false]

attribute :note, :string
validates :note, presence: true, if: -> { passed == false }

def save
return false if invalid?

VerifyRequestable.call(requestable:, user:, passed:, note:)
ReceiveRequestable.call(requestable:, user:) unless requestable.received?

VerifyRequestable.call(requestable:, user:, passed:, note: "") if passed

true
end
Expand Down
Loading

0 comments on commit c5b6905

Please sign in to comment.