Browse Source

Changes to how organisation id passed across each view & start on prepare your file page

pull/2629/head
Manny Dinssa 2 years ago
parent
commit
2e5d113bef
  1. 10
      app/controllers/bulk_upload_lettings_logs_controller.rb
  2. 10
      app/controllers/bulk_upload_sales_logs_controller.rb
  3. 1
      app/models/forms/bulk_upload_lettings/checking_file.rb
  4. 3
      app/models/forms/bulk_upload_lettings/guidance.rb
  5. 5
      app/models/forms/bulk_upload_lettings/needstype.rb
  6. 8
      app/models/forms/bulk_upload_lettings/prepare_your_file.rb
  7. 13
      app/models/forms/bulk_upload_lettings/upload_your_file.rb
  8. 9
      app/models/forms/bulk_upload_lettings/year.rb
  9. 1
      app/models/forms/bulk_upload_sales/checking_file.rb
  10. 3
      app/models/forms/bulk_upload_sales/guidance.rb
  11. 5
      app/models/forms/bulk_upload_sales/prepare_your_file.rb
  12. 8
      app/models/forms/bulk_upload_sales/upload_your_file.rb
  13. 7
      app/models/forms/bulk_upload_sales/year.rb
  14. 1
      app/views/bulk_upload_lettings_logs/forms/checking_file.html.erb
  15. 1
      app/views/bulk_upload_lettings_logs/forms/needstype.erb
  16. 1
      app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2024.html.erb
  17. 2
      app/views/bulk_upload_lettings_logs/forms/upload_your_file.html.erb
  18. 1
      app/views/bulk_upload_lettings_logs/forms/year.html.erb
  19. 1
      app/views/bulk_upload_sales_logs/forms/checking_file.html.erb
  20. 1
      app/views/bulk_upload_sales_logs/forms/prepare_your_file_2024.html.erb
  21. 2
      app/views/bulk_upload_sales_logs/forms/upload_your_file.html.erb
  22. 1
      app/views/bulk_upload_sales_logs/forms/year.html.erb
  23. 4
      app/views/logs/_create_for_org_actions.html.erb

10
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

10
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

1
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"

3
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

5
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

8
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

13
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))

9
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!

1
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"

3
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

5
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

8
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

7
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

1
app/views/bulk_upload_lettings_logs/forms/checking_file.html.erb

@ -6,6 +6,7 @@
<div class="govuk-grid-column-two-thirds">
<%= form_with model: @form, scope: :form, url: bulk_upload_lettings_log_path(id: "prepare-your-file"), method: :patch do |f| %>
<%= f.hidden_field :year %>
<%= f.hidden_field :organisation_id %>
<span class="govuk-caption-l">Upload lettings logs in bulk (<%= @form.year_combo %>)</span>
<h1 class="govuk-heading-l">We’re checking the file</h1>

1
app/views/bulk_upload_lettings_logs/forms/needstype.erb

@ -7,6 +7,7 @@
<%= form_with model: @form, scope: :form, url: bulk_upload_lettings_log_path(id: "needstype"), method: :patch do |f| %>
<%= f.govuk_error_summary %>
<%= f.hidden_field :year %>
<%= f.hidden_field :organisation_id %>
<%= f.govuk_collection_radio_buttons :needstype,
@form.options,

1
app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2024.html.erb

@ -6,6 +6,7 @@
<div class="govuk-grid-column-two-thirds">
<%= form_with model: @form, scope: :form, url: bulk_upload_lettings_log_path(id: "prepare-your-file"), method: :patch do |f| %>
<%= f.hidden_field :year %>
<%= f.hidden_field :organisation_id %>
<span class="govuk-caption-l">Upload lettings logs in bulk (<%= @form.year_combo %>)</span>
<h1 class="govuk-heading-l">Prepare your file</h1>

2
app/views/bulk_upload_lettings_logs/forms/upload_your_file.html.erb

@ -7,7 +7,7 @@
<%= form_with model: @form, scope: :form, url: bulk_upload_lettings_log_path(id: "upload-your-file"), method: :patch do |f| %>
<%= f.hidden_field :year %>
<%= f.hidden_field :needstype %>
<%= f.hidden_field :organisation_id, value: params[:organisation_id] %>
<%= f.hidden_field :organisation_id %>
<%= f.govuk_error_summary %>

1
app/views/bulk_upload_lettings_logs/forms/year.html.erb

@ -4,6 +4,7 @@
<%= form_with model: @form, scope: :form, url: bulk_upload_lettings_log_path(id: "year"), method: :patch do |f| %>
<%= f.govuk_error_summary %>
<%= f.hidden_field :organisation_id %>
<%= f.govuk_collection_radio_buttons :year,
@form.options,

1
app/views/bulk_upload_sales_logs/forms/checking_file.html.erb

@ -6,6 +6,7 @@
<div class="govuk-grid-column-two-thirds">
<%= form_with model: @form, scope: :form, url: bulk_upload_sales_log_path(id: "prepare-your-file"), method: :patch do |f| %>
<%= f.hidden_field :year %>
<%= f.hidden_field :organisation_id %><%= f.hidden_field :organisation_id %>
<span class="govuk-caption-l">Upload sales logs in bulk (<%= @form.year_combo %>)</span>
<h1 class="govuk-heading-l">We’re checking the file</h1>

1
app/views/bulk_upload_sales_logs/forms/prepare_your_file_2024.html.erb

@ -6,6 +6,7 @@
<div class="govuk-grid-column-two-thirds">
<%= form_with model: @form, scope: :form, url: bulk_upload_sales_log_path(id: "prepare-your-file"), method: :patch do |f| %>
<%= f.hidden_field :year %>
<%= f.hidden_field :organisation_id %>
<span class="govuk-caption-l">Upload sales logs in bulk (<%= @form.year_combo %>)</span>
<h1 class="govuk-heading-l">Prepare your file</h1>

2
app/views/bulk_upload_sales_logs/forms/upload_your_file.html.erb

@ -6,7 +6,7 @@
<div class="govuk-grid-column-two-thirds">
<%= form_with model: @form, scope: :form, url: bulk_upload_sales_log_path(id: "upload-your-file"), method: :patch do |f| %>
<%= f.hidden_field :year %>
<%= f.hidden_field :organisation_id, value: params[:organisation_id] %>
<%= f.hidden_field :organisation_id %>
<%= f.govuk_error_summary %>

1
app/views/bulk_upload_sales_logs/forms/year.html.erb

@ -4,6 +4,7 @@
<%= form_with model: @form, scope: :form, url: bulk_upload_sales_log_path(id: "year"), method: :patch do |f| %>
<%= f.govuk_error_summary %>
<%= f.hidden_field :organisation_id %>
<%= f.govuk_collection_radio_buttons :year,
@form.options,

4
app/views/logs/_create_for_org_actions.html.erb

@ -2,11 +2,11 @@
<% if @organisation.data_protection_confirmed? %>
<% if current_page?(controller: 'organisations', action: 'lettings_logs') %>
<%= govuk_button_to "Create a new lettings log for this organisation", lettings_logs_path(lettings_log: { owning_organisation_id: @organisation.id }, method: :post), class: "govuk-!-margin-right-6" %>
<%= govuk_button_link_to "Upload lettings logs in bulk", bulk_upload_lettings_log_path(id: "upload-your-file", form: { year: FormHandler.instance.current_collection_start_year }, organisation_id: @organisation.id), secondary: true %>
<%= govuk_button_link_to "Upload lettings logs in bulk", bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year: FormHandler.instance.current_collection_start_year, organisation_id: @organisation.id }), secondary: true %>
<% end %>
<% if current_page?(controller: 'organisations', action: 'sales_logs') %>
<%= govuk_button_to "Create a new sales log for this organisation", sales_logs_path(sales_log: { owning_organisation_id: @organisation.id }, method: :post), class: "govuk-!-margin-right-6" %>
<%= govuk_button_link_to "Upload sales logs in bulk", bulk_upload_sales_log_path(id: "upload-your-file", form: { year: FormHandler.instance.current_collection_start_year }, organisation_id: @organisation.id), secondary: true %>
<%= govuk_button_link_to "Upload sales logs in bulk", bulk_upload_sales_log_path(id: "prepare-your-file", form: { year: FormHandler.instance.current_collection_start_year, organisation_id: @organisation.id }), secondary: true %>
<% end %>
<% end %>
</div>

Loading…
Cancel
Save