diff --git a/app/controllers/bulk_upload_lettings_logs_controller.rb b/app/controllers/bulk_upload_lettings_logs_controller.rb index c7d78df5c..b9bd9895d 100644 --- a/app/controllers/bulk_upload_lettings_logs_controller.rb +++ b/app/controllers/bulk_upload_lettings_logs_controller.rb @@ -3,12 +3,10 @@ class BulkUploadLettingsLogsController < ApplicationController before_action :validate_data_protection_agrement_signed! def start - if current_user.support? && params[:organisation_id].present? - redirect_to bulk_upload_lettings_log_path(id: "upload-your-file", form: { year: current_year }, organisation_id: params[:organisation_id]) - elsif have_choice_of_year? - redirect_to bulk_upload_lettings_log_path(id: "year") + if have_choice_of_year? + redirect_to bulk_upload_lettings_log_path(id: "year", form: { organisation_id: }) else - redirect_to bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year: current_year }) + redirect_to bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year: current_year, organisation_id: }) end end @@ -53,7 +51,7 @@ private when "needstype" Forms::BulkUploadLettings::Needstype.new(form_params) when "upload-your-file" - Forms::BulkUploadLettings::UploadYourFile.new(form_params.merge(current_user:, request:)) + Forms::BulkUploadLettings::UploadYourFile.new(form_params.merge(current_user:)) when "checking-file" Forms::BulkUploadLettings::CheckingFile.new(form_params) else diff --git a/app/controllers/bulk_upload_sales_logs_controller.rb b/app/controllers/bulk_upload_sales_logs_controller.rb index 923fa2bd6..dcb1772e9 100644 --- a/app/controllers/bulk_upload_sales_logs_controller.rb +++ b/app/controllers/bulk_upload_sales_logs_controller.rb @@ -3,12 +3,10 @@ class BulkUploadSalesLogsController < ApplicationController before_action :validate_data_protection_agrement_signed! def start - if current_user.support? && params[:organisation_id].present? - redirect_to bulk_upload_sales_log_path(id: "upload-your-file", form: { year: current_year }, organisation_id: params[:organisation_id]) - elsif have_choice_of_year? - redirect_to bulk_upload_sales_log_path(id: "year") + if have_choice_of_year? + redirect_to bulk_upload_sales_log_path(id: "year", form: { organisation_id: }) else - redirect_to bulk_upload_sales_log_path(id: "prepare-your-file", form: { year: current_year }) + redirect_to bulk_upload_sales_log_path(id: "prepare-your-file", form: { year: current_year, organisation_id: }) end end @@ -51,7 +49,7 @@ private when "guidance" Forms::BulkUploadSales::Guidance.new(form_params.merge(referrer: params[:referrer])) when "upload-your-file" - Forms::BulkUploadSales::UploadYourFile.new(form_params.merge(current_user:, request:)) + Forms::BulkUploadSales::UploadYourFile.new(form_params.merge(current_user:)) when "checking-file" Forms::BulkUploadSales::CheckingFile.new(form_params) else diff --git a/app/models/forms/bulk_upload_lettings/checking_file.rb b/app/models/forms/bulk_upload_lettings/checking_file.rb index 8cd9ee696..7f3741efd 100644 --- a/app/models/forms/bulk_upload_lettings/checking_file.rb +++ b/app/models/forms/bulk_upload_lettings/checking_file.rb @@ -6,6 +6,7 @@ module Forms include Rails.application.routes.url_helpers attribute :year, :integer + attribute :organisation_id, :integer def view_path "bulk_upload_lettings_logs/forms/checking_file" diff --git a/app/models/forms/bulk_upload_lettings/guidance.rb b/app/models/forms/bulk_upload_lettings/guidance.rb index b6cf5bf74..dde51f261 100644 --- a/app/models/forms/bulk_upload_lettings/guidance.rb +++ b/app/models/forms/bulk_upload_lettings/guidance.rb @@ -7,6 +7,7 @@ module Forms attribute :year, :integer attribute :referrer + attribute :organisation_id, :integer def view_path "bulk_upload_shared/guidance" @@ -15,7 +16,7 @@ module Forms def back_path case referrer when "prepare-your-file" - bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year: }) + bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year:, organisation_id: }) when "home" root_path else diff --git a/app/models/forms/bulk_upload_lettings/needstype.rb b/app/models/forms/bulk_upload_lettings/needstype.rb index 0cadd647c..d018ae498 100644 --- a/app/models/forms/bulk_upload_lettings/needstype.rb +++ b/app/models/forms/bulk_upload_lettings/needstype.rb @@ -7,6 +7,7 @@ module Forms attribute :needstype, :integer attribute :year, :integer + attribute :organisation_id, :integer validates :needstype, presence: true @@ -19,11 +20,11 @@ module Forms end def back_path - bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year:, needstype: }) + bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year:, needstype:, organisation_id: }) end def next_path - bulk_upload_lettings_log_path(id: "upload-your-file", form: { year:, needstype: }) + bulk_upload_lettings_log_path(id: "upload-your-file", form: { year:, needstype:, organisation_id: }) end def year_combo diff --git a/app/models/forms/bulk_upload_lettings/prepare_your_file.rb b/app/models/forms/bulk_upload_lettings/prepare_your_file.rb index b5069d908..b7d504642 100644 --- a/app/models/forms/bulk_upload_lettings/prepare_your_file.rb +++ b/app/models/forms/bulk_upload_lettings/prepare_your_file.rb @@ -7,6 +7,7 @@ module Forms attribute :year, :integer attribute :needstype, :integer + attribute :organisation_id, :integer def view_path case year @@ -19,15 +20,16 @@ module Forms def back_path if have_choice_of_year? - Rails.application.routes.url_helpers.bulk_upload_lettings_log_path(id: "year", form: { year: }) + Rails.application.routes.url_helpers.bulk_upload_lettings_log_path(id: "year", form: { year:, organisation_id: }) + elsif organisation_id.present? + lettings_logs_organisation_path(organisation_id) else Rails.application.routes.url_helpers.lettings_logs_path end end def next_path - page_id = year == 2022 ? "needstype" : "upload-your-file" - bulk_upload_lettings_log_path(id: page_id, form: { year:, needstype: }) + bulk_upload_lettings_log_path(id: "upload-your-file", form: { year:, needstype:, organisation_id: }) end def legacy_template_path diff --git a/app/models/forms/bulk_upload_lettings/upload_your_file.rb b/app/models/forms/bulk_upload_lettings/upload_your_file.rb index f501da811..256fb971b 100644 --- a/app/models/forms/bulk_upload_lettings/upload_your_file.rb +++ b/app/models/forms/bulk_upload_lettings/upload_your_file.rb @@ -12,7 +12,6 @@ module Forms attribute :file attribute :current_user attribute :organisation_id, :integer - attr_accessor :request validates :file, presence: true validate :validate_file_is_csv @@ -22,13 +21,7 @@ module Forms end def back_path - organisation_id = request.query_parameters[:organisation_id] - if organisation_id.present? - lettings_logs_organisation_path(organisation_id) - else - page_id = year == 2022 ? "needstype" : "prepare-your-file" - bulk_upload_lettings_log_path(id: page_id, form: { year:, needstype: }) - end + bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year:, needstype:, organisation_id: }) end def year_combo @@ -36,7 +29,7 @@ module Forms end def next_path - bulk_upload_lettings_log_path(id: "checking-file", form: { year: }) + bulk_upload_lettings_log_path(id: "checking-file", form: { year:, organisation_id: }) end def save! @@ -46,7 +39,7 @@ module Forms year:, needstype:, filename: file.original_filename, - organisation_id: organisation_id || current_user.organisation_id, + organisation_id:, ) storage_service.write_file(bulk_upload.identifier, File.read(file.path)) diff --git a/app/models/forms/bulk_upload_lettings/year.rb b/app/models/forms/bulk_upload_lettings/year.rb index e199559fa..52f4900d6 100644 --- a/app/models/forms/bulk_upload_lettings/year.rb +++ b/app/models/forms/bulk_upload_lettings/year.rb @@ -6,6 +6,7 @@ module Forms include Rails.application.routes.url_helpers attribute :year, :integer + attribute :organisation_id, :integer validates :year, presence: true @@ -20,11 +21,15 @@ module Forms end def back_path - lettings_logs_path + if organisation_id.present? + lettings_logs_organisation_path(organisation_id) + else + lettings_logs_path + end end def next_path - bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year: }) + bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year:, organisation_id: }) end def save! diff --git a/app/models/forms/bulk_upload_sales/checking_file.rb b/app/models/forms/bulk_upload_sales/checking_file.rb index a37be3ccb..299bba663 100644 --- a/app/models/forms/bulk_upload_sales/checking_file.rb +++ b/app/models/forms/bulk_upload_sales/checking_file.rb @@ -6,6 +6,7 @@ module Forms include Rails.application.routes.url_helpers attribute :year, :integer + attribute :organisation_id, :integer def view_path "bulk_upload_sales_logs/forms/checking_file" diff --git a/app/models/forms/bulk_upload_sales/guidance.rb b/app/models/forms/bulk_upload_sales/guidance.rb index 28ca6c3b5..e838c62df 100644 --- a/app/models/forms/bulk_upload_sales/guidance.rb +++ b/app/models/forms/bulk_upload_sales/guidance.rb @@ -7,6 +7,7 @@ module Forms attribute :year, :integer attribute :referrer + attribute :organisation_id, :integer def view_path "bulk_upload_shared/guidance" @@ -15,7 +16,7 @@ module Forms def back_path case referrer when "prepare-your-file" - bulk_upload_sales_log_path(id: "prepare-your-file", form: { year: }) + bulk_upload_sales_log_path(id: "prepare-your-file", form: { year:, organisation_id: }) when "home" root_path else diff --git a/app/models/forms/bulk_upload_sales/prepare_your_file.rb b/app/models/forms/bulk_upload_sales/prepare_your_file.rb index 387f6239f..1019ecf77 100644 --- a/app/models/forms/bulk_upload_sales/prepare_your_file.rb +++ b/app/models/forms/bulk_upload_sales/prepare_your_file.rb @@ -6,6 +6,7 @@ module Forms include Rails.application.routes.url_helpers attribute :year, :integer + attribute :organisation_id, :integer def view_path case year @@ -19,13 +20,15 @@ module Forms def back_path if have_choice_of_year? Rails.application.routes.url_helpers.bulk_upload_sales_log_path(id: "year", form: { year: }) + elsif organisation_id.present? + sales_logs_organisation_path(organisation_id) else Rails.application.routes.url_helpers.sales_logs_path end end def next_path - bulk_upload_sales_log_path(id: "upload-your-file", form: { year: }) + bulk_upload_sales_log_path(id: "upload-your-file", form: { year:, organisation_id: }) end def legacy_template_path diff --git a/app/models/forms/bulk_upload_sales/upload_your_file.rb b/app/models/forms/bulk_upload_sales/upload_your_file.rb index 83cc12def..49c884908 100644 --- a/app/models/forms/bulk_upload_sales/upload_your_file.rb +++ b/app/models/forms/bulk_upload_sales/upload_your_file.rb @@ -11,7 +11,6 @@ module Forms attribute :file attribute :current_user attribute :organisation_id, :integer - attr_accessor :request validates :file, presence: true validate :validate_file_is_csv @@ -21,12 +20,7 @@ module Forms end def back_path - organisation_id = request.query_parameters[:organisation_id] - if organisation_id.present? - sales_logs_organisation_path(organisation_id) - else - bulk_upload_sales_log_path(id: "prepare-your-file", form: { year: }) - end + bulk_upload_sales_log_path(id: "prepare-your-file", form: { year:, organisation_id: }) end def year_combo diff --git a/app/models/forms/bulk_upload_sales/year.rb b/app/models/forms/bulk_upload_sales/year.rb index 85959c4e5..769f566c0 100644 --- a/app/models/forms/bulk_upload_sales/year.rb +++ b/app/models/forms/bulk_upload_sales/year.rb @@ -6,6 +6,7 @@ module Forms include Rails.application.routes.url_helpers attribute :year, :integer + attribute :organisation_id, :integer validates :year, presence: true @@ -20,7 +21,11 @@ module Forms end def back_path - sales_logs_path + if organisation_id.present? + sales_logs_organisation_path(organisation_id) + else + sales_logs_path + end end def next_path diff --git a/app/views/bulk_upload_lettings_logs/forms/checking_file.html.erb b/app/views/bulk_upload_lettings_logs/forms/checking_file.html.erb index 7524072a5..2e6d4cd10 100644 --- a/app/views/bulk_upload_lettings_logs/forms/checking_file.html.erb +++ b/app/views/bulk_upload_lettings_logs/forms/checking_file.html.erb @@ -6,6 +6,7 @@