diff --git a/app/controllers/start_controller.rb b/app/controllers/start_controller.rb index 0d48c00e9..9994843ac 100644 --- a/app/controllers/start_controller.rb +++ b/app/controllers/start_controller.rb @@ -29,6 +29,14 @@ class StartController < ApplicationController ) end + def download_22_23_lettings_form + send_file( + Rails.root.join("public/files/2022_23_lettings_paper_form.pdf"), + filename: "2022-23 Lettings paper form.pdf", + type: "application/pdf", + ) + end + def download_23_24_lettings_bulk_upload_template send_file( Rails.root.join("public/files/bulk-upload-lettings-template-2023-24.xlsx"), diff --git a/app/helpers/collection_resources_helper.rb b/app/helpers/collection_resources_helper.rb new file mode 100644 index 000000000..8cf79ebdf --- /dev/null +++ b/app/helpers/collection_resources_helper.rb @@ -0,0 +1,13 @@ +module CollectionResourcesHelper + def metadata_helper(file, pages = nil) + extension = file.split(".")[-1] + type_string = case extension + when "xlsx" then "Microsoft Excel" + when "pdf" then "PDF" + else extension + end + size = number_to_human_size(File.size("public/files/#{file}"), precision: 0, significant: false) + pages_string = pages.present? ? pluralize(pages, "page") : nil + [type_string, size, pages_string].compact.join(", ") + end +end diff --git a/app/views/layouts/_collection_resources.html.erb b/app/views/layouts/_collection_resources.html.erb index 254cf9acd..741061308 100644 --- a/app/views/layouts/_collection_resources.html.erb +++ b/app/views/layouts/_collection_resources.html.erb @@ -7,22 +7,22 @@ { name: "Lettings log for tenants (2023/24)", href: download_23_24_lettings_form_path, - metadata: "PDF, 278 KB, 8 pages", + metadata: metadata_helper("2023_24_lettings_paper_form.pdf", 8) }, { name: "Lettings bulk upload template (2023/24) – New question ordering", href: download_23_24_lettings_bulk_upload_template_path, - metadata: "Microsoft Excel, 15 KB", + metadata: metadata_helper("bulk-upload-lettings-template-2023-24.xlsx"), }, { name: "Lettings bulk upload template (2023/24)", href: download_23_24_lettings_bulk_upload_legacy_template_path, - metadata: "Microsoft Excel, 15 KB", + metadata: metadata_helper("bulk-upload-lettings-legacy-template-2023-24.xlsx"), }, { name: "Lettings bulk upload specification (2023/24)", href: download_23_24_lettings_bulk_upload_specification_path, - metadata: "Microsoft Excel, 90 KB", + metadata: metadata_helper("bulk-upload-lettings-specification-2023-24.xlsx"), }, ]) %> @@ -31,22 +31,22 @@ { name: "Sales log for buyers (2023/24)", href: download_23_24_sales_form_path, - metadata: "PDF, 421 KB, 8 pages", + metadata: metadata_helper("2023_24_sales_paper_form.pdf", 8), }, { name: "Sales bulk upload template (2023/24) – New question ordering", href: download_23_24_sales_bulk_upload_template_path, - metadata: "Microsoft Excel, 21 KB", + metadata: metadata_helper("bulk-upload-sales-template-2023-24.xlsx"), }, { name: "Sales bulk upload template (2023/24)", href: download_23_24_sales_bulk_upload_legacy_template_path, - metadata: "Microsoft Excel, 21 KB", + metadata: metadata_helper("bulk-upload-sales-legacy-template-2023-24.xlsx"), }, { name: "Sales bulk upload specification (2023/24)", href: download_23_24_sales_bulk_upload_specification_path, - metadata: "Microsoft Excel, 38 KB", + metadata: metadata_helper("bulk-upload-sales-specification-2023-24.xlsx"), }, ]) %> @@ -54,18 +54,18 @@ <%= render DocumentListComponent.new(items: [ { name: "Lettings log for tenants (2022/23)", - href: "https://core.communities.gov.uk/public/download/guides-and-manuals/2022-23%20Lettings%20paper%20form.pdf?download-format=pdf", - metadata: "PDF, 654 KB, 4 pages", + href: download_22_23_lettings_form_path, + metadata: metadata_helper("2022_23_lettings_paper_form.pdf", 4), }, { name: "Lettings bulk upload template (2022/23)", href: download_22_23_lettings_bulk_upload_template_path, - metadata: "Microsoft Excel, 36 KB", + metadata: metadata_helper("bulk-upload-lettings-template-2022-23.xlsx"), }, { name: "Lettings bulk upload specification (2022/23)", href: download_22_23_lettings_bulk_upload_specification_path, - metadata: "Microsoft Excel, 53 KB", + metadata: metadata_helper("bulk-upload-lettings-specification-2022-23.xlsx"), }, ]) %> @@ -74,17 +74,17 @@ { name: "Sales log for buyers (2022/23)", href: download_22_23_sales_form_path, - metadata: "PDF, 397 KB, 5 pages", + metadata: metadata_helper("2022_23_sales_paper_form.pdf", 5), }, { name: "Sales bulk upload template (2022/23)", href: download_22_23_sales_bulk_upload_template_path, - metadata: "Microsoft Excel, 14 KB", + metadata: metadata_helper("bulk-upload-sales-template-2022-23.xlsx"), }, { name: "Sales bulk upload specification (2022/23)", href: download_22_23_sales_bulk_upload_specification_path, - metadata: "Microsoft Excel, 24 KB", + metadata: metadata_helper("bulk-upload-sales-template-2022-23.xlsx"), }, ]) %> diff --git a/config/routes.rb b/config/routes.rb index 6d3d6dcbe..1a58967af 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -37,6 +37,7 @@ Rails.application.routes.draw do get "/data-sharing-agreement", to: "content#data_sharing_agreement" get "/download-23-24-lettings-form", to: "start#download_23_24_lettings_form" + get "/download-22-23-lettings-form", to: "start#download_22_23_lettings_form" get "/download-23-24-lettings-bulk-upload-template", to: "start#download_23_24_lettings_bulk_upload_template" get "/download-23-24-lettings-bulk-upload-legacy-template", to: "start#download_23_24_lettings_bulk_upload_legacy_template" get "/download-23-24-lettings-bulk-upload-specification", to: "start#download_23_24_lettings_bulk_upload_specification" diff --git a/public/files/2022_23_lettings_paper_form.pdf b/public/files/2022_23_lettings_paper_form.pdf new file mode 100644 index 000000000..9de28a0c0 Binary files /dev/null and b/public/files/2022_23_lettings_paper_form.pdf differ diff --git a/public/files/bulk-upload-sales-legacy-template-2023-24.xlsx b/public/files/bulk-upload-sales-legacy-template-2023-24.xlsx index 068943f40..531775d00 100644 Binary files a/public/files/bulk-upload-sales-legacy-template-2023-24.xlsx and b/public/files/bulk-upload-sales-legacy-template-2023-24.xlsx differ diff --git a/public/files/bulk-upload-sales-template-2023-24.xlsx b/public/files/bulk-upload-sales-template-2023-24.xlsx index a8654c09a..905995f59 100644 Binary files a/public/files/bulk-upload-sales-template-2023-24.xlsx and b/public/files/bulk-upload-sales-template-2023-24.xlsx differ