Skip to content

Commit

Permalink
Add record Ecctis response page
Browse files Browse the repository at this point in the history
This adds the page which admins will use to record the response from
Ecctis in to the system so the application can be processed.
  • Loading branch information
thomasleese committed Feb 29, 2024
1 parent b2c5c25 commit d9e494a
Show file tree
Hide file tree
Showing 20 changed files with 298 additions and 409 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ class QualificationRequestsController < BaseController
]
before_action :set_member_variables,
only: %i[
edit
update
edit_consent_method
update_consent_method
edit_request
update_request
edit_verify
update_verify
edit_verify_failed
update_verify_failed
edit_review
update_review
]
Expand Down Expand Up @@ -77,55 +79,6 @@ def generate_unsigned_consent_document
)
end

def edit
received =
if requestable.received?
true
elsif requestable.expired?
false
end

passed = (requestable.review_passed if requestable.received?)

failed =
if requestable.expired?
case requestable.review_passed
when true
false
when false
true
end
end

@form =
QualificationRequestForm.new(
requestable:,
user: current_staff,
received:,
passed:,
note: requestable.review_note,
failed:,
)
end

def update
@form =
QualificationRequestForm.new(
form_params.merge(requestable:, user: current_staff),
)

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

def edit_consent_method
@form =
ConsentMethodForm.new(
Expand Down Expand Up @@ -201,6 +154,74 @@ def update_request
end
end

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

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

if @form.save
if @form.passed
redirect_to [
:assessor_interface,
application_form,
assessment,
:qualification_requests,
]
else
redirect_to [
:verify_failed,
:assessor_interface,
application_form,
assessment,
qualification_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(
requestable:,
user: current_staff,
**verify_failed_form_params,
)

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

def edit_review
@form = RequestableReviewForm.new(requestable:)
end
Expand All @@ -210,7 +231,7 @@ def update_review
RequestableReviewForm.new(
requestable:,
user: current_staff,
**requestable_review_form_params,
**review_form_params,
)

if @form.save
Expand Down Expand Up @@ -268,15 +289,6 @@ def generate_unsigned_consent_document_form_params
).permit(:generated)
end

def form_params
params.require(:assessor_interface_qualification_request_form).permit(
:received,
:passed,
:note,
:failed,
)
end

def consent_method_form_params
params.require(:assessor_interface_consent_method_form).permit(
:consent_method,
Expand All @@ -289,11 +301,23 @@ def upload_unsigned_consent_document_form_params
).permit(:original_attachment)
end

def requestable_review_form_params
def review_form_params
params.require(:assessor_interface_requestable_review_form).permit(
: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
end
end
59 changes: 0 additions & 59 deletions app/forms/assessor_interface/qualification_request_form.rb

This file was deleted.

47 changes: 23 additions & 24 deletions app/models/assessment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,6 @@ def can_decline?
elsif request_further_information?
all_further_information_requests_reviewed? &&
any_further_information_requests_failed?
elsif verify?
if professional_standing_request_verify_failed? ||
any_reference_requests_verify_failed? ||
any_consent_requests_verify_failed?
return false
end

return false unless all_consent_requests_verified?
return false unless all_qualification_requests_reviewed?
return false unless all_reference_requests_verified?
return false unless professional_standing_request_verified?

any_qualification_requests_review_failed?
elsif review?
return false unless all_consent_requests_reviewed?
return false unless all_qualification_requests_reviewed?
Expand Down Expand Up @@ -165,7 +152,7 @@ def can_review?
return false unless application_form.created_under_new_regulations?

return false unless all_consent_requests_verified?
return false unless all_qualification_requests_reviewed?
return false unless all_qualification_requests_verified?
return false unless all_reference_requests_verified?
return false unless professional_standing_request_verified?

Expand Down Expand Up @@ -215,10 +202,6 @@ def any_not_preliminary_section_finished?
sections.not_preliminary.any?(&:finished?)
end

def all_reference_requests_verified?
reference_requests.all?(&:verified?)
end

def enough_reference_requests_verify_passed?
return false if any_reference_requests_verify_failed?

Expand Down Expand Up @@ -287,14 +270,18 @@ def enough_reference_requests_review_passed?
).enough_for_submission?
end

def any_reference_requests_verify_failed?
reference_requests.any?(&:verify_failed?)
end

def any_reference_requests_review_failed?
reference_requests.any?(&:review_failed?)
end

def all_reference_requests_verified?
reference_requests.all?(&:verified?)
end

def any_reference_requests_verify_failed?
reference_requests.any?(&:verify_failed?)
end

def all_consent_requests_reviewed?
consent_requests.where(verify_passed: false).all?(&:reviewed?)
end
Expand Down Expand Up @@ -326,17 +313,29 @@ def all_qualification_requests_reviewed?
if all_consent_requests_verified? && any_consent_requests_verify_failed?
return true
end
qualification_requests.all?(&:reviewed?)

qualification_requests.where(verify_passed: false).all?(&:reviewed?)
end

def all_qualification_requests_review_passed?
qualification_requests.all?(&:review_passed?)
qualification_requests.all? do |qualification_request|
qualification_request.verify_passed? ||
qualification_request.review_passed?
end
end

def any_qualification_requests_review_failed?
qualification_requests.any?(&:review_failed?)
end

def all_qualification_requests_verified?
qualification_requests.all?(&:verified?)
end

def all_qualification_requests_verify_passed?
qualification_requests.all?(&:verify_passed?)
end

def any_qualification_requests_verify_failed?
qualification_requests.any?(&:verify_failed?)
end
Expand Down
16 changes: 12 additions & 4 deletions app/policies/assessor_interface/qualification_request_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ def generate_unsigned_consent_document?
user.verify_permission
end

def update?
user.verify_permission
end

def update_consent_method?
user.verify_permission
end
Expand All @@ -40,6 +36,18 @@ def update_request?

alias_method :edit_request?, :update_request?

def update_verify?
user.verify_permission
end

alias_method :edit_verify?, :update_verify?

def update_verify_failed?
user.verify_permission
end

alias_method :edit_verify_failed?, :update_verify_failed?

def update_review?
user.assess_permission
end
Expand Down
Loading

0 comments on commit d9e494a

Please sign in to comment.