From 17df5ec2c3d2cf179f6aef6f7451c76b899591c7 Mon Sep 17 00:00:00 2001 From: Frankie Roberto Date: Tue, 9 Jun 2020 16:31:56 +0100 Subject: [PATCH] Rename controllers (#699) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This renames some controllers, to better handle the conflict between the controllers that handle creating things (eg corrective actions) and those that handle viewing the things. Conventionally these would be the same controller, but because the creation controllers use the `show` action as part of the creation flow (via WickedWizard), these conflict. This PR follows [a suggestion](https://github.com/UKGovernmentBEIS/beis-opss-psd/pull/687#pullrequestreview-426273229) from @slorek to rename the creation controllers as `RecordThingController` so that the view controllers can be `ThingController`, instead of `ViewThingController`. This will allow us to more easily merge the creation controllers back into the regular controllers, when we get around to refactoring away from using WickedWizard. ### Changes #### Corrective actions `ViewCorrectiveActionsController` ➡️ `CorrectiveActionsController` `CorrectiveActionsController` ➡️ `RecordCorrectiveActionsController` #### Correspondence `ViewEmailsController` ➡️ `EmailsController` `EmailsController` ➡️ `RecordEmailsController` `ViewPhoneCallsController` ➡️ `PhoneCallsController` `PhoneCallsController` ➡️ `RecordPhoneCallsController` `ViewMeetingsController` ➡️ `MeetingsController` `MeetingsController` ➡️ `RecordMeetingsController` --- .../corrective_actions_controller.rb | 89 +----------------- .../investigations/emails_controller.rb | 81 ++--------------- .../investigations/meetings_controller.rb | 69 ++------------ .../investigations/phone_calls_controller.rb | 61 ++----------- .../record_corrective_actions_controller.rb | 90 +++++++++++++++++++ .../record_emails_controller.rb | 78 ++++++++++++++++ .../record_meetings_controller.rb | 66 ++++++++++++++ .../record_phone_calls_controller.rb | 58 ++++++++++++ .../view_corrective_actions_controller.rb | 9 -- .../investigations/view_emails_controller.rb | 10 --- .../view_meetings_controller.rb | 9 -- .../view_phone_calls_controller.rb | 9 -- .../_form.html.slim | 0 .../confirmation.html.slim | 0 .../details.html.slim | 2 +- .../confirmation.html.erb | 0 .../content.html.slim | 0 .../context.html.slim | 0 .../confirmation.html.erb | 0 .../content.html.slim | 0 .../context.html.slim | 0 .../confirmation.html.erb | 0 .../content.html.slim | 0 .../context.html.slim | 0 .../corrective_action.html.slim | 2 +- psd-web/config/routes.rb | 16 ++-- 26 files changed, 320 insertions(+), 329 deletions(-) create mode 100644 psd-web/app/controllers/investigations/record_corrective_actions_controller.rb create mode 100644 psd-web/app/controllers/investigations/record_emails_controller.rb create mode 100644 psd-web/app/controllers/investigations/record_meetings_controller.rb create mode 100644 psd-web/app/controllers/investigations/record_phone_calls_controller.rb delete mode 100644 psd-web/app/controllers/investigations/view_corrective_actions_controller.rb delete mode 100644 psd-web/app/controllers/investigations/view_emails_controller.rb delete mode 100644 psd-web/app/controllers/investigations/view_meetings_controller.rb delete mode 100644 psd-web/app/controllers/investigations/view_phone_calls_controller.rb rename psd-web/app/views/investigations/{corrective_actions => record_corrective_actions}/_form.html.slim (100%) rename psd-web/app/views/investigations/{corrective_actions => record_corrective_actions}/confirmation.html.slim (100%) rename psd-web/app/views/investigations/{corrective_actions => record_corrective_actions}/details.html.slim (93%) rename psd-web/app/views/investigations/{emails => record_emails}/confirmation.html.erb (100%) rename psd-web/app/views/investigations/{emails => record_emails}/content.html.slim (100%) rename psd-web/app/views/investigations/{emails => record_emails}/context.html.slim (100%) rename psd-web/app/views/investigations/{meetings => record_meetings}/confirmation.html.erb (100%) rename psd-web/app/views/investigations/{meetings => record_meetings}/content.html.slim (100%) rename psd-web/app/views/investigations/{meetings => record_meetings}/context.html.slim (100%) rename psd-web/app/views/investigations/{phone_calls => record_phone_calls}/confirmation.html.erb (100%) rename psd-web/app/views/investigations/{phone_calls => record_phone_calls}/content.html.slim (100%) rename psd-web/app/views/investigations/{phone_calls => record_phone_calls}/context.html.slim (100%) diff --git a/psd-web/app/controllers/investigations/corrective_actions_controller.rb b/psd-web/app/controllers/investigations/corrective_actions_controller.rb index 5982254ee9..946e3ceb7e 100644 --- a/psd-web/app/controllers/investigations/corrective_actions_controller.rb +++ b/psd-web/app/controllers/investigations/corrective_actions_controller.rb @@ -1,90 +1,7 @@ class Investigations::CorrectiveActionsController < ApplicationController - include CorrectiveActionsConcern - include FileConcern - set_attachment_names :file - set_file_params_key :corrective_action - - include Wicked::Wizard - steps :details, :confirmation - - before_action :set_investigation - before_action :set_corrective_action, only: %i[show create update] - before_action :set_attachment, only: %i[show create update] - before_action :store_corrective_action, only: %i[update] - - # GET /corrective_actions/1 def show - authorize @investigation, :update? - render_wizard - end - - # GET /corrective_actions/new - def new - clear_session - redirect_to wizard_path(steps.first, request.query_parameters) - end - - # POST /corrective_actions - # POST /corrective_actions.json - def create - authorize @investigation, :update? - respond_to do |format| - update_attachment - if corrective_action_saved? - format.html { redirect_to investigation_url(@investigation), flash: { success: "Corrective action was successfully recorded." } } - format.json { render :show, status: :created, location: @corrective_action } - else - format.html { render step } - format.json { render json: @corrective_action.errors, status: :unprocessable_entity } - end - end - end - - # PATCH/PUT /corrective_actions/1 - # PATCH/PUT /corrective_actions/1.json - def update - authorize @investigation, :update? - respond_to do |format| - update_attachment - if corrective_action_valid? - save_attachment - format.html { redirect_to next_wizard_path } - format.json { render :show, status: :ok, location: @corrective_action } - else - format.html { render step } - format.json { render json: @corrective_action.errors, status: :unprocessable_entity } - end - end - end - -private - - def clear_session - session[:corrective_action] = nil - initialize_file_attachments - end - - def store_corrective_action - session[:corrective_action] = @corrective_action.attributes if @corrective_action.valid?(step) - end - - def corrective_action_saved? - return false unless corrective_action_valid? - - # In addition to attaching to the test, we also attach to the investigation, so the file is surfaced in the ui - attach_blobs_to_list(@file_blob, @investigation.documents) - @corrective_action.save - end - - def save_attachment - if params[:corrective_action][:related_file] == "Yes" - @file_blob.save if @file_blob - elsif @file_blob - @file_blob.purge - end - end - - def corrective_action_session_params - session[:corrective_action] || {} + @investigation = Investigation.find_by!(pretty_id: params[:investigation_pretty_id]) + authorize @investigation, :view_non_protected_details? + @corrective_action = @investigation.corrective_actions.find(params[:id]) end end diff --git a/psd-web/app/controllers/investigations/emails_controller.rb b/psd-web/app/controllers/investigations/emails_controller.rb index ecb3d0f688..198d14bb42 100644 --- a/psd-web/app/controllers/investigations/emails_controller.rb +++ b/psd-web/app/controllers/investigations/emails_controller.rb @@ -1,78 +1,7 @@ -class Investigations::EmailsController < Investigations::CorrespondenceController - set_file_params_key :correspondence_email - set_attachment_names :email_file, :email_attachment - -private - - def audit_class - AuditActivity::Correspondence::AddEmail - end - - def model_class - Correspondence::Email - end - - def common_file_metadata - { - title: correspondence_params["overview"], - has_consumer_info: correspondence_params["has_consumer_info"] - } - end - - def email_file_metadata - get_attachment_metadata_params(:email_file) - .merge(common_file_metadata) - .merge( - description: "Original email as a file" - ) - end - - def email_attachment_metadata - get_attachment_metadata_params(:email_attachment) - .merge(common_file_metadata) - end - - def request_params - return {} if params[correspondence_params_key].blank? - - params.require(correspondence_params_key).permit( - :correspondent_name, - :email_address, - :email_direction, - :overview, - :details, - :email_subject, - :attachment_description, - :has_consumer_info - ) - end - - def set_attachments - @email_file_blob, @email_attachment_blob = load_file_attachments - end - - def update_attachments - update_blob_metadata @email_file_blob, email_file_metadata - update_blob_metadata @email_attachment_blob, email_attachment_metadata - end - - def correspondence_valid? - @correspondence.validate(step || steps.last) - @correspondence.validate_email_file_and_content(@email_file_blob) if step == :content - validate_blob_size(@email_file_blob, @correspondence.errors, "email file") - validate_blob_size(@email_attachment_blob, @correspondence.errors, "email attachment") - Rails.logger.error "#{__method__}: correspondence has errors: #{@correspondence.errors.full_messages}" if @correspondence.errors.any? - @correspondence.errors.empty? - end - - def attach_files - attach_blob_to_attachment_slot(@email_file_blob, @correspondence.email_file) - attach_blob_to_attachment_slot(@email_attachment_blob, @correspondence.email_attachment) - attach_blobs_to_list(@email_file_blob, @email_attachment_blob, @investigation.documents) - end - - def save_attachments - @email_file_blob.save if @email_file_blob - @email_attachment_blob.save if @email_attachment_blob +class Investigations::EmailsController < ApplicationController + def show + @investigation = Investigation.find_by!(pretty_id: params[:investigation_pretty_id]) + authorize @investigation, :view_protected_details? + @email = @investigation.emails.find(params[:id]).decorate end end diff --git a/psd-web/app/controllers/investigations/meetings_controller.rb b/psd-web/app/controllers/investigations/meetings_controller.rb index 2fe203c8e0..2c8ca0a8ab 100644 --- a/psd-web/app/controllers/investigations/meetings_controller.rb +++ b/psd-web/app/controllers/investigations/meetings_controller.rb @@ -1,66 +1,7 @@ -class Investigations::MeetingsController < Investigations::CorrespondenceController - set_attachment_names :transcript, :related_attachment - set_file_params_key :correspondence_meeting - -private - - def audit_class - AuditActivity::Correspondence::AddMeeting - end - - def model_class - Correspondence::Meeting - end - - def transcript_metadata - get_attachment_metadata_params(:transcript).merge( - title: correspondence_params["overview"], - description: "Meeting transcript" - ) - end - - def related_attachment_metadata - get_attachment_metadata_params(:related_attachment).merge( - title: correspondence_params["overview"] - ) - end - - def request_params - return {} if params[correspondence_params_key].blank? - - params.require(correspondence_params_key).permit( - :correspondent_name, - :overview, - :details, - :has_consumer_info - ) - end - - def set_attachments - @transcript_blob, @related_attachment_blob = load_file_attachments - end - - def update_attachments - update_blob_metadata @transcript_blob, transcript_metadata - update_blob_metadata @related_attachment_blob, related_attachment_metadata - end - - def correspondence_valid? - @correspondence.validate(step || steps.last) - @correspondence.validate_transcript_and_content(@transcript_blob) if step == :content - validate_blob_size(@transcript_blob, @correspondence.errors, "transcript") - validate_blob_size(@related_attachment_blob, @correspondence.errors, "related attachment") - @correspondence.errors.empty? - end - - def attach_files - attach_blob_to_attachment_slot(@transcript_blob, @correspondence.transcript) - attach_blob_to_attachment_slot(@related_attachment_blob, @correspondence.related_attachment) - attach_blobs_to_list(@transcript_blob, @related_attachment_blob, @investigation.documents) - end - - def save_attachments - @transcript_blob.save if @transcript_blob - @related_attachment_blob.save if @related_attachment_blob +class Investigations::MeetingsController < ApplicationController + def show + @investigation = Investigation.find_by!(pretty_id: params[:investigation_pretty_id]) + authorize @investigation, :view_protected_details? + @meeting = @investigation.meetings.find(params[:id]).decorate end end diff --git a/psd-web/app/controllers/investigations/phone_calls_controller.rb b/psd-web/app/controllers/investigations/phone_calls_controller.rb index 023fe471b7..4c2a264afd 100644 --- a/psd-web/app/controllers/investigations/phone_calls_controller.rb +++ b/psd-web/app/controllers/investigations/phone_calls_controller.rb @@ -1,58 +1,7 @@ -class Investigations::PhoneCallsController < Investigations::CorrespondenceController - set_attachment_names :transcript - set_file_params_key :correspondence_phone_call - -private - - def audit_class - AuditActivity::Correspondence::AddPhoneCall - end - - def model_class - Correspondence::PhoneCall - end - - def file_metadata - get_attachment_metadata_params(:transcript).merge( - title: correspondence_params["overview"], - description: "Call transcript", - has_consumer_info: correspondence_params["has_consumer_info"] - ) - end - - def request_params - return {} if params[correspondence_params_key].blank? - - params.require(correspondence_params_key).permit( - :correspondent_name, - :phone_number, - :overview, - :details, - :has_consumer_info - ) - end - - def set_attachments - @transcript_blob, * = load_file_attachments - end - - def update_attachments - update_blob_metadata @transcript_blob, file_metadata - end - - def correspondence_valid? - @correspondence.validate(step || steps.last) - @correspondence.validate_transcript_and_content(@transcript_blob) if step == :content - validate_blob_size(@transcript_blob, @correspondence.errors, "file") - @correspondence.errors.empty? - end - - def attach_files - attach_blob_to_attachment_slot(@transcript_blob, @correspondence.transcript) - attach_blobs_to_list(@transcript_blob, @investigation.documents) - end - - def save_attachments - @transcript_blob.save if @transcript_blob +class Investigations::PhoneCallsController < ApplicationController + def show + @investigation = Investigation.find_by!(pretty_id: params[:investigation_pretty_id]) + authorize @investigation, :view_protected_details? + @phone_call = @investigation.phone_calls.find(params[:id]).decorate end end diff --git a/psd-web/app/controllers/investigations/record_corrective_actions_controller.rb b/psd-web/app/controllers/investigations/record_corrective_actions_controller.rb new file mode 100644 index 0000000000..c26ab7b167 --- /dev/null +++ b/psd-web/app/controllers/investigations/record_corrective_actions_controller.rb @@ -0,0 +1,90 @@ +class Investigations::RecordCorrectiveActionsController < ApplicationController + include CorrectiveActionsConcern + include FileConcern + set_attachment_names :file + set_file_params_key :corrective_action + + include Wicked::Wizard + steps :details, :confirmation + + before_action :set_investigation + before_action :set_corrective_action, only: %i[show create update] + before_action :set_attachment, only: %i[show create update] + before_action :store_corrective_action, only: %i[update] + + # GET /corrective_actions/1 + def show + authorize @investigation, :update? + render_wizard + end + + # GET /corrective_actions/new + def new + clear_session + redirect_to wizard_path(steps.first, request.query_parameters) + end + + # POST /corrective_actions + # POST /corrective_actions.json + def create + authorize @investigation, :update? + respond_to do |format| + update_attachment + if corrective_action_saved? + format.html { redirect_to investigation_url(@investigation), flash: { success: "Corrective action was successfully recorded." } } + format.json { render :show, status: :created, location: @corrective_action } + else + format.html { render step } + format.json { render json: @corrective_action.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /corrective_actions/1 + # PATCH/PUT /corrective_actions/1.json + def update + authorize @investigation, :update? + respond_to do |format| + update_attachment + if corrective_action_valid? + save_attachment + format.html { redirect_to next_wizard_path } + format.json { render :show, status: :ok, location: @corrective_action } + else + format.html { render step } + format.json { render json: @corrective_action.errors, status: :unprocessable_entity } + end + end + end + +private + + def clear_session + session[:corrective_action] = nil + initialize_file_attachments + end + + def store_corrective_action + session[:corrective_action] = @corrective_action.attributes if @corrective_action.valid?(step) + end + + def corrective_action_saved? + return false unless corrective_action_valid? + + # In addition to attaching to the test, we also attach to the investigation, so the file is surfaced in the ui + attach_blobs_to_list(@file_blob, @investigation.documents) + @corrective_action.save + end + + def save_attachment + if params[:corrective_action][:related_file] == "Yes" + @file_blob.save if @file_blob + elsif @file_blob + @file_blob.purge + end + end + + def corrective_action_session_params + session[:corrective_action] || {} + end +end diff --git a/psd-web/app/controllers/investigations/record_emails_controller.rb b/psd-web/app/controllers/investigations/record_emails_controller.rb new file mode 100644 index 0000000000..cd0ac96d27 --- /dev/null +++ b/psd-web/app/controllers/investigations/record_emails_controller.rb @@ -0,0 +1,78 @@ +class Investigations::RecordEmailsController < Investigations::CorrespondenceController + set_file_params_key :correspondence_email + set_attachment_names :email_file, :email_attachment + +private + + def audit_class + AuditActivity::Correspondence::AddEmail + end + + def model_class + Correspondence::Email + end + + def common_file_metadata + { + title: correspondence_params["overview"], + has_consumer_info: correspondence_params["has_consumer_info"] + } + end + + def email_file_metadata + get_attachment_metadata_params(:email_file) + .merge(common_file_metadata) + .merge( + description: "Original email as a file" + ) + end + + def email_attachment_metadata + get_attachment_metadata_params(:email_attachment) + .merge(common_file_metadata) + end + + def request_params + return {} if params[correspondence_params_key].blank? + + params.require(correspondence_params_key).permit( + :correspondent_name, + :email_address, + :email_direction, + :overview, + :details, + :email_subject, + :attachment_description, + :has_consumer_info + ) + end + + def set_attachments + @email_file_blob, @email_attachment_blob = load_file_attachments + end + + def update_attachments + update_blob_metadata @email_file_blob, email_file_metadata + update_blob_metadata @email_attachment_blob, email_attachment_metadata + end + + def correspondence_valid? + @correspondence.validate(step || steps.last) + @correspondence.validate_email_file_and_content(@email_file_blob) if step == :content + validate_blob_size(@email_file_blob, @correspondence.errors, "email file") + validate_blob_size(@email_attachment_blob, @correspondence.errors, "email attachment") + Rails.logger.error "#{__method__}: correspondence has errors: #{@correspondence.errors.full_messages}" if @correspondence.errors.any? + @correspondence.errors.empty? + end + + def attach_files + attach_blob_to_attachment_slot(@email_file_blob, @correspondence.email_file) + attach_blob_to_attachment_slot(@email_attachment_blob, @correspondence.email_attachment) + attach_blobs_to_list(@email_file_blob, @email_attachment_blob, @investigation.documents) + end + + def save_attachments + @email_file_blob.save if @email_file_blob + @email_attachment_blob.save if @email_attachment_blob + end +end diff --git a/psd-web/app/controllers/investigations/record_meetings_controller.rb b/psd-web/app/controllers/investigations/record_meetings_controller.rb new file mode 100644 index 0000000000..85fe92d6a1 --- /dev/null +++ b/psd-web/app/controllers/investigations/record_meetings_controller.rb @@ -0,0 +1,66 @@ +class Investigations::RecordMeetingsController < Investigations::CorrespondenceController + set_attachment_names :transcript, :related_attachment + set_file_params_key :correspondence_meeting + +private + + def audit_class + AuditActivity::Correspondence::AddMeeting + end + + def model_class + Correspondence::Meeting + end + + def transcript_metadata + get_attachment_metadata_params(:transcript).merge( + title: correspondence_params["overview"], + description: "Meeting transcript" + ) + end + + def related_attachment_metadata + get_attachment_metadata_params(:related_attachment).merge( + title: correspondence_params["overview"] + ) + end + + def request_params + return {} if params[correspondence_params_key].blank? + + params.require(correspondence_params_key).permit( + :correspondent_name, + :overview, + :details, + :has_consumer_info + ) + end + + def set_attachments + @transcript_blob, @related_attachment_blob = load_file_attachments + end + + def update_attachments + update_blob_metadata @transcript_blob, transcript_metadata + update_blob_metadata @related_attachment_blob, related_attachment_metadata + end + + def correspondence_valid? + @correspondence.validate(step || steps.last) + @correspondence.validate_transcript_and_content(@transcript_blob) if step == :content + validate_blob_size(@transcript_blob, @correspondence.errors, "transcript") + validate_blob_size(@related_attachment_blob, @correspondence.errors, "related attachment") + @correspondence.errors.empty? + end + + def attach_files + attach_blob_to_attachment_slot(@transcript_blob, @correspondence.transcript) + attach_blob_to_attachment_slot(@related_attachment_blob, @correspondence.related_attachment) + attach_blobs_to_list(@transcript_blob, @related_attachment_blob, @investigation.documents) + end + + def save_attachments + @transcript_blob.save if @transcript_blob + @related_attachment_blob.save if @related_attachment_blob + end +end diff --git a/psd-web/app/controllers/investigations/record_phone_calls_controller.rb b/psd-web/app/controllers/investigations/record_phone_calls_controller.rb new file mode 100644 index 0000000000..70b7d97503 --- /dev/null +++ b/psd-web/app/controllers/investigations/record_phone_calls_controller.rb @@ -0,0 +1,58 @@ +class Investigations::RecordPhoneCallsController < Investigations::CorrespondenceController + set_attachment_names :transcript + set_file_params_key :correspondence_phone_call + +private + + def audit_class + AuditActivity::Correspondence::AddPhoneCall + end + + def model_class + Correspondence::PhoneCall + end + + def file_metadata + get_attachment_metadata_params(:transcript).merge( + title: correspondence_params["overview"], + description: "Call transcript", + has_consumer_info: correspondence_params["has_consumer_info"] + ) + end + + def request_params + return {} if params[correspondence_params_key].blank? + + params.require(correspondence_params_key).permit( + :correspondent_name, + :phone_number, + :overview, + :details, + :has_consumer_info + ) + end + + def set_attachments + @transcript_blob, * = load_file_attachments + end + + def update_attachments + update_blob_metadata @transcript_blob, file_metadata + end + + def correspondence_valid? + @correspondence.validate(step || steps.last) + @correspondence.validate_transcript_and_content(@transcript_blob) if step == :content + validate_blob_size(@transcript_blob, @correspondence.errors, "file") + @correspondence.errors.empty? + end + + def attach_files + attach_blob_to_attachment_slot(@transcript_blob, @correspondence.transcript) + attach_blobs_to_list(@transcript_blob, @investigation.documents) + end + + def save_attachments + @transcript_blob.save if @transcript_blob + end +end diff --git a/psd-web/app/controllers/investigations/view_corrective_actions_controller.rb b/psd-web/app/controllers/investigations/view_corrective_actions_controller.rb deleted file mode 100644 index ac75321d20..0000000000 --- a/psd-web/app/controllers/investigations/view_corrective_actions_controller.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Investigations::ViewCorrectiveActionsController < ApplicationController - def show - @investigation = Investigation.find_by!(pretty_id: params[:investigation_pretty_id]) - authorize @investigation, :view_non_protected_details? - @corrective_action = @investigation.corrective_actions.find(params[:id]) - - render "investigations/corrective_actions/show" - end -end diff --git a/psd-web/app/controllers/investigations/view_emails_controller.rb b/psd-web/app/controllers/investigations/view_emails_controller.rb deleted file mode 100644 index 401ec78b5a..0000000000 --- a/psd-web/app/controllers/investigations/view_emails_controller.rb +++ /dev/null @@ -1,10 +0,0 @@ -class Investigations::ViewEmailsController < ApplicationController - def show - @investigation = Investigation.find_by!(pretty_id: params[:investigation_pretty_id]) - authorize @investigation, :view_protected_details? - - @email = @investigation.emails.find(params[:id]).decorate - - render "investigations/emails/show" - end -end diff --git a/psd-web/app/controllers/investigations/view_meetings_controller.rb b/psd-web/app/controllers/investigations/view_meetings_controller.rb deleted file mode 100644 index ac8e1b4c65..0000000000 --- a/psd-web/app/controllers/investigations/view_meetings_controller.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Investigations::ViewMeetingsController < ApplicationController - def show - @investigation = Investigation.find_by!(pretty_id: params[:investigation_pretty_id]) - authorize @investigation, :view_protected_details? - @meeting = @investigation.meetings.find(params[:id]).decorate - - render "investigations/meetings/show" - end -end diff --git a/psd-web/app/controllers/investigations/view_phone_calls_controller.rb b/psd-web/app/controllers/investigations/view_phone_calls_controller.rb deleted file mode 100644 index 6d5309b612..0000000000 --- a/psd-web/app/controllers/investigations/view_phone_calls_controller.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Investigations::ViewPhoneCallsController < ApplicationController - def show - @investigation = Investigation.find_by!(pretty_id: params[:investigation_pretty_id]) - authorize @investigation, :view_protected_details? - @phone_call = @investigation.phone_calls.find(params[:id]).decorate - - render "investigations/phone_calls/show" - end -end diff --git a/psd-web/app/views/investigations/corrective_actions/_form.html.slim b/psd-web/app/views/investigations/record_corrective_actions/_form.html.slim similarity index 100% rename from psd-web/app/views/investigations/corrective_actions/_form.html.slim rename to psd-web/app/views/investigations/record_corrective_actions/_form.html.slim diff --git a/psd-web/app/views/investigations/corrective_actions/confirmation.html.slim b/psd-web/app/views/investigations/record_corrective_actions/confirmation.html.slim similarity index 100% rename from psd-web/app/views/investigations/corrective_actions/confirmation.html.slim rename to psd-web/app/views/investigations/record_corrective_actions/confirmation.html.slim diff --git a/psd-web/app/views/investigations/corrective_actions/details.html.slim b/psd-web/app/views/investigations/record_corrective_actions/details.html.slim similarity index 93% rename from psd-web/app/views/investigations/corrective_actions/details.html.slim rename to psd-web/app/views/investigations/record_corrective_actions/details.html.slim index 150f2e8a8e..f0e33b5e8e 100644 --- a/psd-web/app/views/investigations/corrective_actions/details.html.slim +++ b/psd-web/app/views/investigations/record_corrective_actions/details.html.slim @@ -12,7 +12,7 @@ span.govuk-caption-l = @investigation.pretty_description h1.govuk-heading-l = page_title - = render "investigations/corrective_actions/form", + = render "investigations/record_corrective_actions/form", form: form, corrective_action: @corrective_action, investigation: @investigation, diff --git a/psd-web/app/views/investigations/emails/confirmation.html.erb b/psd-web/app/views/investigations/record_emails/confirmation.html.erb similarity index 100% rename from psd-web/app/views/investigations/emails/confirmation.html.erb rename to psd-web/app/views/investigations/record_emails/confirmation.html.erb diff --git a/psd-web/app/views/investigations/emails/content.html.slim b/psd-web/app/views/investigations/record_emails/content.html.slim similarity index 100% rename from psd-web/app/views/investigations/emails/content.html.slim rename to psd-web/app/views/investigations/record_emails/content.html.slim diff --git a/psd-web/app/views/investigations/emails/context.html.slim b/psd-web/app/views/investigations/record_emails/context.html.slim similarity index 100% rename from psd-web/app/views/investigations/emails/context.html.slim rename to psd-web/app/views/investigations/record_emails/context.html.slim diff --git a/psd-web/app/views/investigations/meetings/confirmation.html.erb b/psd-web/app/views/investigations/record_meetings/confirmation.html.erb similarity index 100% rename from psd-web/app/views/investigations/meetings/confirmation.html.erb rename to psd-web/app/views/investigations/record_meetings/confirmation.html.erb diff --git a/psd-web/app/views/investigations/meetings/content.html.slim b/psd-web/app/views/investigations/record_meetings/content.html.slim similarity index 100% rename from psd-web/app/views/investigations/meetings/content.html.slim rename to psd-web/app/views/investigations/record_meetings/content.html.slim diff --git a/psd-web/app/views/investigations/meetings/context.html.slim b/psd-web/app/views/investigations/record_meetings/context.html.slim similarity index 100% rename from psd-web/app/views/investigations/meetings/context.html.slim rename to psd-web/app/views/investigations/record_meetings/context.html.slim diff --git a/psd-web/app/views/investigations/phone_calls/confirmation.html.erb b/psd-web/app/views/investigations/record_phone_calls/confirmation.html.erb similarity index 100% rename from psd-web/app/views/investigations/phone_calls/confirmation.html.erb rename to psd-web/app/views/investigations/record_phone_calls/confirmation.html.erb diff --git a/psd-web/app/views/investigations/phone_calls/content.html.slim b/psd-web/app/views/investigations/record_phone_calls/content.html.slim similarity index 100% rename from psd-web/app/views/investigations/phone_calls/content.html.slim rename to psd-web/app/views/investigations/record_phone_calls/content.html.slim diff --git a/psd-web/app/views/investigations/phone_calls/context.html.slim b/psd-web/app/views/investigations/record_phone_calls/context.html.slim similarity index 100% rename from psd-web/app/views/investigations/phone_calls/context.html.slim rename to psd-web/app/views/investigations/record_phone_calls/context.html.slim diff --git a/psd-web/app/views/investigations/ts_investigations/corrective_action.html.slim b/psd-web/app/views/investigations/ts_investigations/corrective_action.html.slim index b70b13c6f1..680c85709c 100644 --- a/psd-web/app/views/investigations/ts_investigations/corrective_action.html.slim +++ b/psd-web/app/views/investigations/ts_investigations/corrective_action.html.slim @@ -6,7 +6,7 @@ hide_break: false, further_key: :further_corrective_action do |form| - = render "investigations/corrective_actions/form", + = render "investigations/record_corrective_actions/form", form: form, corrective_action: @corrective_action, investigation: @investigation, diff --git a/psd-web/config/routes.rb b/psd-web/config/routes.rb index ef4a7695f0..c74756a588 100644 --- a/psd-web/config/routes.rb +++ b/psd-web/config/routes.rb @@ -131,20 +131,20 @@ end end - resources :phone_calls, controller: "investigations/view_phone_calls", only: :show, constraints: { id: /\d+/ }, path: "phone-calls" - resources :emails, controller: "investigations/view_emails", only: :show, constraints: { id: /\d+/ } - resources :meetings, controller: "investigations/view_meetings", only: :show, constraints: { id: /\d+/ } + resources :phone_calls, controller: "investigations/phone_calls", only: :show, constraints: { id: /\d+/ }, path: "phone-calls" + resources :emails, controller: "investigations/emails", only: :show, constraints: { id: /\d+/ } + resources :meetings, controller: "investigations/meetings", only: :show, constraints: { id: /\d+/ } resources :ownership, controller: "investigations/ownership", only: %i[show new create update], path: "assign" - resources :corrective_actions, controller: "investigations/corrective_actions", only: %i[show new create update] - resources :emails, controller: "investigations/emails", only: %i[show new create update] - resources :phone_calls, controller: "investigations/phone_calls", only: %i[show new create update] - resources :meetings, controller: "investigations/meetings", only: %i[show new create update] + resources :corrective_actions, controller: "investigations/record_corrective_actions", only: %i[show new create update] + resources :emails, controller: "investigations/record_emails", only: %i[show new create update] + resources :phone_calls, controller: "investigations/record_phone_calls", only: %i[show new create update] + resources :meetings, controller: "investigations/record_meetings", only: %i[show new create update] resources :alerts, controller: "investigations/alerts", only: %i[show new create update] resources :test_results, controller: "investigations/test_results", only: :show, path: "test-results" - resources :actions, controller: "investigations/view_corrective_actions", only: :show, path: "corrective-actions" + resources :actions, controller: "investigations/corrective_actions", only: :show, path: "corrective-actions" resources :tests, controller: "investigations/tests", only: %i[show create update] do collection do