Skip to content

Commit

Permalink
Merge pull request #2259 from DFE-Digital/already-received-consent
Browse files Browse the repository at this point in the history
Skip submission page if consent already received
  • Loading branch information
thomasleese authored Jun 14, 2024
2 parents e182141 + 143e2e7 commit 5f76019
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions app/controllers/teacher_interface/consent_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,18 @@ def check
end

def submit
consent_requests = application_form.assessment.consent_requests

if consent_requests.all?(&:received?)
redirect_to %i[teacher_interface application_form]
end

ActiveRecord::Base.transaction do
application_form.assessment.consent_requests.each do |requestable|
ReceiveRequestable.call(requestable:, user: current_teacher)
end
consent_requests
.reject(&:received?)
.each do |requestable|
ReceiveRequestable.call(requestable:, user: current_teacher)
end
end

DeliverEmail.call(
Expand Down

0 comments on commit 5f76019

Please sign in to comment.