Skip to content

Commit

Permalink
Skip submission page if consent already received
Browse files Browse the repository at this point in the history
This is to prevent users pressing back and trying to re-submit the
consent that they have already submitted. It doesn't affect many users,
but they'll see an error page.

https://dfe-teacher-services.sentry.io/issues/5391729885/
  • Loading branch information
thomasleese committed Jun 14, 2024
1 parent e182141 commit 143e2e7
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 143e2e7

Please sign in to comment.