-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2037 from DFE-Digital/consent-requests
Refactor consent requests
- Loading branch information
Showing
52 changed files
with
667 additions
and
637 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
app/controllers/teacher_interface/consent_requests_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# frozen_string_literal: true | ||
|
||
module TeacherInterface | ||
class ConsentRequestsController < BaseController | ||
include HandleApplicationFormSection | ||
include HistoryTrackable | ||
|
||
before_action :load_consent_request, only: %i[edit_download update_download] | ||
|
||
define_history_check :check | ||
define_history_origin :index | ||
define_history_reset :index | ||
|
||
def index | ||
@view_object = ConsentRequestsViewObject.new(application_form:) | ||
end | ||
|
||
def check | ||
@view_object = ConsentRequestsViewObject.new(application_form:) | ||
end | ||
|
||
def submit | ||
ActiveRecord::Base.transaction do | ||
application_form.assessment.consent_requests.each do |requestable| | ||
ReceiveRequestable.call(requestable:, user: current_teacher) | ||
end | ||
end | ||
|
||
TeacherMailer.with(application_form:).consent_submitted.deliver_later | ||
|
||
redirect_to %i[teacher_interface application_form] | ||
end | ||
|
||
def edit_download | ||
@form = | ||
DownloadUnsignedConsentDocumentForm.new( | ||
consent_request:, | ||
downloaded: consent_request.unsigned_document_downloaded, | ||
) | ||
end | ||
|
||
def update_download | ||
@form = | ||
DownloadUnsignedConsentDocumentForm.new( | ||
consent_request:, | ||
downloaded: | ||
params.dig( | ||
:teacher_interface_download_unsigned_consent_document_form, | ||
:downloaded, | ||
), | ||
) | ||
|
||
handle_application_form_section( | ||
form: @form, | ||
if_success_then_redirect: | ||
teacher_interface_application_form_consent_requests_path, | ||
if_failure_then_render: :edit_download, | ||
) | ||
end | ||
|
||
private | ||
|
||
attr_reader :consent_request | ||
|
||
def load_consent_request | ||
@consent_request = | ||
ConsentRequest | ||
.joins(assessment: :application_form) | ||
.includes(:qualification, :application_form) | ||
.find_by!(id: params[:id], assessment: { application_form: }) | ||
|
||
@qualification = consent_request.qualification | ||
end | ||
end | ||
end |
77 changes: 0 additions & 77 deletions
77
app/controllers/teacher_interface/qualification_requests_controller.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
app/forms/teacher_interface/download_unsigned_consent_document_form.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module TeacherInterface | ||
class DownloadUnsignedConsentDocumentForm < BaseForm | ||
attr_accessor :consent_request | ||
attribute :downloaded, :boolean | ||
|
||
validates :consent_request, presence: true | ||
validates :downloaded, presence: true | ||
|
||
def update_model | ||
consent_request.update!(unsigned_document_downloaded: true) if downloaded | ||
end | ||
end | ||
end |
19 changes: 0 additions & 19 deletions
19
app/forms/teacher_interface/qualification_request_download_form.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.