Skip to content

Commit

Permalink
Add submitting consent
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasleese committed Feb 19, 2024
1 parent 4dca5f7 commit 02de96f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,6 +20,7 @@ class QualificationRequestsController < BaseController
]

define_history_origin :index
define_history_check :check_consent_methods

def index
@view_object =
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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 %>

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

<%= render "shared/assessor_interface/continue_cancel_button", f: %>
<% end %>
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 02de96f

Please sign in to comment.