Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add qualification verification journey #1888

Merged
merged 17 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/assets/stylesheets/application.sass.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,7 @@ ul.autocomplete__menu {
text-align: right;
vertical-align: middle;
}

.app-background-inset-text {
background-color: #f3f2f1;
}
9 changes: 3 additions & 6 deletions app/components/status_tag/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,18 @@ def tags
not_started: "grey",
overdue: "pink",
overdue_consent: "pink",
overdue_ecctis: "pink",
overdue_further_information: "pink",
overdue_lops: "pink",
overdue_professional_standing: "pink",
overdue_qualification: "pink",
overdue_reference: "pink",
potential_duplicate_in_dqt: "pink",
pre_assessment: "pink",
preliminary_check: "pink",
received: "purple",
received_consent: "purple",
received_ecctis: "purple",
received_further_information: "purple",
received_lops: "purple",
received_professional_standing: "purple",
received_qualification: "purple",
received_reference: "purple",
rejected: "red",
requested: "yellow",
Expand All @@ -63,10 +61,9 @@ def tags
verification_not_started: "grey",
waiting_on: "yellow",
waiting_on_consent: "yellow",
waiting_on_ecctis: "yellow",
waiting_on_further_information: "yellow",
waiting_on_lops: "yellow",
waiting_on_professional_standing: "yellow",
waiting_on_qualification: "yellow",
waiting_on_reference: "yellow",
withdrawn: "red",
}.freeze
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ def edit
@professional_standing_request =
assessment.professional_standing_request if assessment.professional_standing_request&.verify_failed?

@consent_requests =
assessment
.consent_requests
.includes(:qualification)
.where(verify_passed: false)
.order_by_role

@qualification_requests =
assessment
.qualification_requests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def update
user: current_staff,
professional_standing:,
qualifications:,
qualifications_assessor_note: session[:qualifications_assessor_note],
work_histories:,
)

Expand Down Expand Up @@ -80,6 +81,9 @@ def update_verify_qualifications
session[:qualification_ids] = []

if @form.verify_qualifications
# To ensure the user goes back to the check page afterwards.
history_stack.pop if history_stack.last_entry_is_check?

redirect_to [
:qualification_requests,
:assessor_interface,
Expand All @@ -106,12 +110,7 @@ def update_verify_qualifications
def edit_qualification_requests
authorize %i[assessor_interface assessment_recommendation], :edit?

@form =
SelectQualificationsForm.new(
application_form:,
session:,
qualification_ids: application_form.qualifications.pluck(:id),
)
@form = SelectQualificationsForm.new(application_form:, session:)
end

def update_qualification_requests
Expand All @@ -123,19 +122,26 @@ def update_qualification_requests
:qualification_ids,
).compact_blank

qualifications_assessor_note =
params.dig(
:assessor_interface_select_qualifications_form,
:qualifications_assessor_note,
) || ""

@form =
SelectQualificationsForm.new(
application_form:,
session:,
qualification_ids:,
qualifications_assessor_note:,
session:,
)

if @form.save
if (check_path = history_stack.last_path_if_check)
redirect_to check_path
else
redirect_to [
:email_consent_letters,
:professional_standing,
:assessor_interface,
application_form,
assessment,
Expand All @@ -147,13 +153,6 @@ def update_qualification_requests
end
end

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

@qualifications =
application_form.qualifications.where(id: session[:qualification_ids])
end

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

Expand Down
191 changes: 189 additions & 2 deletions app/controllers/assessor_interface/consent_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,181 @@ module AssessorInterface
class ConsentRequestsController < BaseController
include HistoryTrackable

before_action :set_variables
before_action :set_collection_variables,
only: %i[new edit_request update_request]
before_action :set_member_variables,
only: %i[
edit_upload
update_upload
check_upload
edit_verify
update_verify
edit_verify_failed
update_verify_failed
edit_review
update_review
]

skip_before_action :track_history, only: :new

def new
qualification =
application_form.qualifications.find(params[:qualification_id])

redirect_to [
:check_upload,
:assessor_interface,
application_form,
assessment,
consent_requests.find_or_create_by(qualification:),
]
end

def edit_request
end

def update_request
if consent_requests.present?
ActiveRecord::Base.transaction do
consent_requests.each do |requestable|
RequestRequestable.call(requestable:, user: current_staff)
end

application_form.reload

ApplicationFormStatusUpdater.call(
application_form:,
user: current_staff,
)
end

TeacherMailer.with(application_form:).consent_requested.deliver_later
end

redirect_to [
:assessor_interface,
application_form,
assessment,
:qualification_requests,
]
end

def edit_upload
@form = UploadUnsignedConsentDocumentForm.new(consent_request:)
end

def update_upload
@form =
UploadUnsignedConsentDocumentForm.new(
consent_request:,
original_attachment:
params.dig(
:assessor_interface_upload_unsigned_consent_document_form,
:original_attachment,
),
)

if @form.save
if (check_path = history_stack.last_path_if_check)
redirect_to check_path
else
redirect_to [
:assessor_interface,
application_form,
assessment,
:qualification_requests,
]
end
else
render :edit_upload, status: :unprocessable_entity
end
end

def check_upload
unless consent_request.unsigned_consent_document.completed? &&
consent_request.unsigned_consent_document.downloadable?
history_stack.pop

redirect_to [
:upload,
:assessor_interface,
application_form,
assessment,
consent_request,
]
end
end

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

def update_verify
passed =
params.dig(:assessor_interface_requestable_verify_passed_form, :passed)

@form =
RequestableVerifyPassedForm.new(
requestable:,
user: current_staff,
passed:,
received: requestable.received?,
)

if passed == "nil" || @form.save
if @form.passed # nil is parsed as true
redirect_to [
:assessor_interface,
application_form,
assessment,
:qualification_requests,
]
else
redirect_to [
:verify_failed,
:assessor_interface,
application_form,
assessment,
consent_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,
:qualification_requests,
]
else
render :edit_verify_failed, status: :unprocessable_entity
end
end

def edit_review
@form = RequestableReviewForm.new(requestable:)
Expand Down Expand Up @@ -51,12 +225,25 @@ def consent_request

alias_method :requestable, :consent_request

def set_variables
def set_collection_variables
authorize %i[assessor_interface consent_request]
@consent_requests = consent_requests
@application_form = application_form
@assessment = assessment
end

def set_member_variables
@consent_request = authorize [:assessor_interface, consent_request]
@application_form = application_form
@assessment = assessment
end

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

def review_form_params
params.require(:assessor_interface_requestable_review_form).permit(
:passed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DocumentsController < BaseController
def show_pdf
authorize %i[assessor_interface application_form]

unless all_uploads_downloadable?
unless document.downloadable?
render "shared/malware_scan"
return
end
Expand All @@ -32,9 +32,5 @@ def show_pdf
def document
@document ||= Document.find(params[:id])
end

def all_uploads_downloadable?
document.uploads.all? { |upload| upload_downloadable?(upload) }
end
end
end
Loading
Loading