diff --git a/app/controllers/collection_resources_controller.rb b/app/controllers/collection_resources_controller.rb index 9f534da33..7e84dc28c 100644 --- a/app/controllers/collection_resources_controller.rb +++ b/app/controllers/collection_resources_controller.rb @@ -167,7 +167,11 @@ class CollectionResourcesController < ApplicationController if @collection_resource.save begin CollectionResourcesService.new.upload_collection_resource(@collection_resource.download_filename, @collection_resource.file) - flash[:notice] = "The #{@collection_resource.log_type} #{text_year_range_format(@collection_resource.year)} #{@collection_resource.short_display_name} is now available to users." + flash[:notice] = if displayed_collection_resource_years.include?(@collection_resource.year) + "The #{@collection_resource.log_type} #{text_year_range_format(@collection_resource.year)} #{@collection_resource.short_display_name} is now available to users." + else + "The #{@collection_resource.log_type} #{text_year_range_format(@collection_resource.year)} #{@collection_resource.short_display_name} has been uploaded." + end redirect_to collection_resources_path rescue StandardError @collection_resource.errors.add(:file, :error_uploading) diff --git a/app/helpers/collection_resources_helper.rb b/app/helpers/collection_resources_helper.rb index 9deb13887..1a5887744 100644 --- a/app/helpers/collection_resources_helper.rb +++ b/app/helpers/collection_resources_helper.rb @@ -49,7 +49,7 @@ module CollectionResourcesHelper def document_list_component_items(resources) resources.map do |resource| { - name: "Download the #{resource.display_name}", + name: "Download the #{resource.display_name.downcase}", href: resource.download_path, metadata: file_type_size_and_pages(resource.download_filename), } diff --git a/app/views/collection_resources/edit.html.erb b/app/views/collection_resources/edit.html.erb index 936685e33..6100256c8 100644 --- a/app/views/collection_resources/edit.html.erb +++ b/app/views/collection_resources/edit.html.erb @@ -27,14 +27,16 @@ <% unless @collection_resource.mandatory %> <%= f.govuk_text_field :short_display_name, - label: nil, + label: { text: "Resource type", size: "m" }, hint: { text: safe_join(["This will be used in the download link on the homepage. Do not include the log type or collection year.", content_tag(:br), "For example, if you enter “bulk upload change log”, the download link will say “Download the #{@collection_resource.log_type} bulk upload change log (#{text_year_range_format(@collection_resource.year)})”."]) } %> <% end %> - <%= f.govuk_submit resource_exists ? "Save changes" : "Upload" %> - <%= govuk_button_link_to "Cancel", collection_resources_path, secondary: true %> +
<% end %> diff --git a/app/views/collection_resources/new.html.erb b/app/views/collection_resources/new.html.erb index 43de37c04..f66c56b94 100644 --- a/app/views/collection_resources/new.html.erb +++ b/app/views/collection_resources/new.html.erb @@ -22,13 +22,15 @@ label: { text: "Upload file", size: "m" } %> <%= f.govuk_text_field :short_display_name, - label: nil, + label: { text: "Resource type", size: "m" }, hint: { text: safe_join(["This will be used in the download link on the homepage. Do not include the log type or collection year.", content_tag(:br), "For example, if you enter “bulk upload change log”, the download link will say “Download the #{@collection_resource.log_type} bulk upload change log (#{text_year_range_format(@collection_resource.year)})”."]) } %> - <%= f.govuk_submit "Add resource" %> - <%= govuk_button_link_to "Cancel", collection_resources_path, secondary: true %> + <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index ce3cb518e..112035e68 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -122,7 +122,7 @@ en: file: error_uploading: There was an error uploading this file. blank: Select which file to upload. - above_100_mb: The file is above 100MB. + above_100_mb: File must be 100MB or less. must_be_pdf: The paper form must be a PDF. must_be_xlsx: The %{resource} must be a Microsoft Excel file. @@ -212,7 +212,7 @@ en: file: error_uploading: There was an error uploading this file. blank: Select which file to upload. - above_100_mb: The file is above 100MB. + above_100_mb: File must be 100MB or less. must_be_pdf: The paper form must be a PDF. must_be_xlsx: The %{resource} must be a Microsoft Excel file. short_display_name: diff --git a/spec/features/collection_resources_spec.rb b/spec/features/collection_resources_spec.rb index c6094d843..ad9a370b6 100644 --- a/spec/features/collection_resources_spec.rb +++ b/spec/features/collection_resources_spec.rb @@ -187,7 +187,7 @@ RSpec.describe "Collection resources" do expect(CollectionResource.first.released_to_user).to be_nil expect(CollectionResource.first.display_name).to eq("sales some file (2025 to 2026)") expect(CollectionResource.first.short_display_name).to eq("some file") - expect(page).to have_content("The sales 2025 to 2026 some file is now available to users.") + expect(page).to have_content("The sales 2025 to 2026 some file has been uploaded.") end it "validates file is attached" do