diff --git a/Gemfile.lock b/Gemfile.lock index 808f2c24a..fe5aee68a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -436,6 +436,7 @@ GEM PLATFORMS arm64-darwin-21 arm64-darwin-22 + arm64-darwin-23 x86_64-darwin-19 x86_64-darwin-20 x86_64-darwin-21 diff --git a/app/controllers/bulk_upload_lettings_results_controller.rb b/app/controllers/bulk_upload_lettings_results_controller.rb index a7ea2605a..4281ef4ad 100644 --- a/app/controllers/bulk_upload_lettings_results_controller.rb +++ b/app/controllers/bulk_upload_lettings_results_controller.rb @@ -29,6 +29,12 @@ class BulkUploadLettingsResultsController < ApplicationController authorize @bulk_upload end + def deletion_report + @bulk_upload = BulkUpload.lettings.find(params[:id]) + + authorize @bulk_upload + end + private def reset_logs_filters diff --git a/app/helpers/logs_helper.rb b/app/helpers/logs_helper.rb index c98dedad5..5e7b73d26 100644 --- a/app/helpers/logs_helper.rb +++ b/app/helpers/logs_helper.rb @@ -49,9 +49,10 @@ module LogsHelper end def logs_and_errors_warning(bulk_upload) - this_or_these_errors = bulk_upload.bulk_upload_errors.count == 1 ? "This error" : "These errors" + is_or_are = bulk_upload.total_logs_count == 1 ? "is" : "are" + need_or_needs = bulk_upload.bulk_upload_errors.count == 1 ? "needs" : "need" - "You will upload #{pluralize(bulk_upload.total_logs_count, 'log')}. There are errors in #{pluralize(bulk_upload.logs_with_errors_count, 'log')}, and #{pluralize(bulk_upload.bulk_upload_errors.count, 'error')} in total. #{this_or_these_errors} will need to be fixed on the CORE site." + "There #{is_or_are} #{pluralize(bulk_upload.total_logs_count, 'log')} in this bulk upload with #{pluralize(bulk_upload.bulk_upload_errors.count, 'error')} that still #{need_or_needs} to be fixed after upload." end def logs_and_soft_validations_warning(bulk_upload) @@ -63,4 +64,12 @@ module LogsHelper def bulk_upload_error_summary(bulk_upload) "You have tried to upload #{bulk_upload.total_logs_count ? pluralize(bulk_upload.total_logs_count, 'log') : 'logs'}. There are errors in #{pluralize(bulk_upload.logs_with_errors_count, 'log')}, and #{pluralize(bulk_upload.bulk_upload_errors.count, 'error')} in total." end + + def deleted_errors_warning_text(bulk_upload) + unique_field_count = bulk_upload.bulk_upload_errors.uniq { |e| e.field }.count + this_or_these = unique_field_count == 1 ? "this" : "these" + it_is_or_they_are = unique_field_count == 1 ? "it is" : "they are" + + "#{pluralize(unique_field_count, "answer")} will be deleted because #{it_is_or_they_are} invalid. You will have to answer #{this_or_these} #{"question".pluralize(unique_field_count)} again on the site." + end end diff --git a/app/policies/bulk_upload_policy.rb b/app/policies/bulk_upload_policy.rb index 429661907..2818376d3 100644 --- a/app/policies/bulk_upload_policy.rb +++ b/app/policies/bulk_upload_policy.rb @@ -18,6 +18,10 @@ class BulkUploadPolicy owner? || same_org? || user.support? end + def deletion_report? + owner? || same_org? || user.support? + end + private def owner? diff --git a/app/views/bulk_upload_lettings_results/deletion_report.html.erb b/app/views/bulk_upload_lettings_results/deletion_report.html.erb new file mode 100644 index 000000000..c91be8554 --- /dev/null +++ b/app/views/bulk_upload_lettings_results/deletion_report.html.erb @@ -0,0 +1,27 @@ +
The following cells contain data this is incorrect.
+If you upload the logs, these answers will be deleted. You will have to re-enter the data on the site and resolve these errors.
+If you do not want these answers to be deleted, correct the data in the CSV and upload the file again.
+ +<%= logs_and_errors_warning(@bulk_upload) %>
++ <%= logs_and_errors_warning(@bulk_upload) %> + <%= govuk_link_to "View the error report", deletion_report_bulk_upload_lettings_result_path %> +
+ + + <%= govuk_warning_text text: deleted_errors_warning_text(@bulk_upload) %> <%= form_with model: @form, scope: :form, url: page_bulk_upload_lettings_resume_path(@bulk_upload, page: "confirm"), method: :patch do |f| %> <%= f.govuk_submit "Confirm" %> diff --git a/app/views/bulk_upload_lettings_resume/fix_choice.html.erb b/app/views/bulk_upload_lettings_resume/fix_choice.html.erb index 0a46c8c35..b0293e5cb 100644 --- a/app/views/bulk_upload_lettings_resume/fix_choice.html.erb +++ b/app/views/bulk_upload_lettings_resume/fix_choice.html.erb @@ -18,6 +18,10 @@ <%= @form.recommendation %>You may find it easier to fix the errors in the CSV file if: