From 02de96fb7d42dc8c9e41a823818469b77fca23a6 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Mon, 19 Feb 2024 10:18:54 +0100 Subject: [PATCH] Add submitting consent --- .../qualification_requests_controller.rb | 32 ++++++++++++++++++- .../check_consent_methods.html.erb | 12 +++++++ config/routes.rb | 4 +++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 app/views/assessor_interface/qualification_requests/check_consent_methods.html.erb diff --git a/app/controllers/assessor_interface/qualification_requests_controller.rb b/app/controllers/assessor_interface/qualification_requests_controller.rb index 8385b4bb88..d0c169706f 100644 --- a/app/controllers/assessor_interface/qualification_requests_controller.rb +++ b/app/controllers/assessor_interface/qualification_requests_controller.rb @@ -3,7 +3,12 @@ module AssessorInterface class QualificationRequestsController < BaseController before_action :set_collection_variables, - only: %i[index index_consent_methods consent_letter] + only: %i[ + index + index_consent_methods + check_consent_methods + consent_letter + ] before_action :set_member_variables, only: %i[ edit @@ -15,6 +20,7 @@ class QualificationRequestsController < BaseController ] define_history_origin :index + define_history_check :check_consent_methods def index @view_object = @@ -26,6 +32,30 @@ def index def index_consent_methods end + def check_consent_methods + end + + def submit_consent_methods + requested_qualification_requests = + ActiveRecord::Base.transaction do + qualification_requests + .reject(&:consent_requested) + .select(&:signed_consent_required?) + .each(&:consent_requested!) + end + + if requested_qualification_requests.present? + TeacherMailer.with(application_form:).consent_requested.deliver_later + end + + redirect_to [ + :assessor_interface, + application_form, + assessment, + :qualification_requests, + ] + end + def consent_letter send_data( ConsentLetter.new(application_form:).render_pdf, diff --git a/app/views/assessor_interface/qualification_requests/check_consent_methods.html.erb b/app/views/assessor_interface/qualification_requests/check_consent_methods.html.erb new file mode 100644 index 0000000000..4c3924f7c3 --- /dev/null +++ b/app/views/assessor_interface/qualification_requests/check_consent_methods.html.erb @@ -0,0 +1,12 @@ +<% title = "Consent methods selected" %> + +<% content_for :page_title, title %> +<% content_for :back_link_url, back_history_path(default: assessor_interface_application_form_assessment_qualification_requests_path) %> + +<%= form_with model: @form, url: [:submit_consent_methods, :assessor_interface, @application_form, @assessment, @qualification_request] do |f| %> + <%= f.govuk_error_summary %> + +

<%= title %>

+ + <%= render "shared/assessor_interface/continue_cancel_button", f: %> +<% end %> diff --git a/config/routes.rb b/config/routes.rb index 8c3a96169c..c644094351 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -134,6 +134,10 @@ get "consent-letter", to: "qualification_requests#consent_letter" get "consent-methods", to: "qualification_requests#index_consent_methods" + get "check-consent-methods", + to: "qualification_requests#check_consent_methods" + post "submit-consent-methods", + to: "qualification_requests#submit_consent_methods" end member do