diff --git a/app/controllers/start_controller.rb b/app/controllers/start_controller.rb
index 671b63805..f2b96f557 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"),
@@ -53,6 +61,30 @@ class StartController < ApplicationController
)
end
+ def download_23_24_sales_bulk_upload_template
+ send_file(
+ Rails.root.join("public/files/bulk-upload-sales-template-2023-24.xlsx"),
+ filename: "2023-24-sales-bulk-upload-template.xlsx",
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ )
+ end
+
+ def download_23_24_sales_bulk_upload_legacy_template
+ send_file(
+ Rails.root.join("public/files/bulk-upload-sales-legacy-template-2023-24.xlsx"),
+ filename: "2023-24-sales-bulk-upload-legacy-template.xlsx",
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ )
+ end
+
+ def download_23_24_sales_bulk_upload_specification
+ send_file(
+ Rails.root.join("public/files/bulk-upload-sales-specification-2023-24.xlsx"),
+ filename: "2023-24-sales-bulk-upload-specification.xlsx",
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ )
+ end
+
def download_22_23_lettings_bulk_upload_template
send_file(
Rails.root.join("public/files/bulk-upload-lettings-template-2022-23.xlsx"),
@@ -68,4 +100,20 @@ class StartController < ApplicationController
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
)
end
+
+ def download_22_23_sales_bulk_upload_template
+ send_file(
+ Rails.root.join("public/files/bulk-upload-sales-template-2022-23.xlsx"),
+ filename: "2022-23-sales-bulk-upload-template.xlsx",
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ )
+ end
+
+ def download_22_23_sales_bulk_upload_specification
+ send_file(
+ Rails.root.join("public/files/bulk-upload-sales-specification-2022-23.xlsx"),
+ filename: "2022-23-sales-bulk-upload-specification.xlsx",
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ )
+ end
end
diff --git a/app/helpers/collection_resources_helper.rb b/app/helpers/collection_resources_helper.rb
new file mode 100644
index 000000000..a85670bda
--- /dev/null
+++ b/app/helpers/collection_resources_helper.rb
@@ -0,0 +1,15 @@
+module CollectionResourcesHelper
+ def file_type_size_and_pages(file, number_of_pages: nil)
+ extension_mapping = {
+ "xlsx" => "Microsoft Excel",
+ "pdf" => "PDF",
+ }
+ extension = File.extname(file)[1..]
+
+ file_type = extension_mapping.fetch(extension, extension)
+
+ file_size = number_to_human_size(File.size("public/files/#{file}"), precision: 0, significant: false)
+ file_pages = number_of_pages ? pluralize(number_of_pages, "page") : nil
+ [file_type, file_size, file_pages].compact.join(", ")
+ end
+end
diff --git a/app/views/layouts/_collection_resources.html.erb b/app/views/layouts/_collection_resources.html.erb
index 656442bf4..872e47e13 100644
--- a/app/views/layouts/_collection_resources.html.erb
+++ b/app/views/layouts/_collection_resources.html.erb
@@ -7,22 +7,46 @@
{
name: "Lettings log for tenants (2023/24)",
href: download_23_24_lettings_form_path,
- metadata: "PDF, 278 KB, 8 pages",
+ metadata: file_type_size_and_pages("2023_24_lettings_paper_form.pdf", number_of_pages: 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: file_type_size_and_pages("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: file_type_size_and_pages("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: file_type_size_and_pages("bulk-upload-lettings-specification-2023-24.xlsx"),
+ },
+ ]) %>
+
+
Sales 2023/24
+ <%= render DocumentListComponent.new(items: [
+ {
+ name: "Sales log for buyers (2023/24)",
+ href: download_23_24_sales_form_path,
+ metadata: file_type_size_and_pages("2023_24_sales_paper_form.pdf", number_of_pages: 8),
+ },
+ {
+ name: "Sales bulk upload template (2023/24) – New question ordering",
+ href: download_23_24_sales_bulk_upload_template_path,
+ metadata: file_type_size_and_pages("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: file_type_size_and_pages("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: file_type_size_and_pages("bulk-upload-sales-specification-2023-24.xlsx"),
},
]) %>
@@ -30,27 +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: file_type_size_and_pages("2022_23_lettings_paper_form.pdf", number_of_pages: 4),
},
{
name: "Lettings bulk upload template (2022/23)",
href: download_22_23_lettings_bulk_upload_template_path,
- metadata: "Microsoft Excel, 36 KB",
+ metadata: file_type_size_and_pages("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",
- },
- ]) %>
-
- Sales 2023/24
- <%= render DocumentListComponent.new(items: [
- {
- name: "Sales log for buyers (2023/24)",
- href: download_23_24_sales_form_path,
- metadata: "PDF, 421 KB, 8 pages",
+ metadata: file_type_size_and_pages("bulk-upload-lettings-specification-2022-23.xlsx"),
},
]) %>
@@ -59,7 +74,17 @@
{
name: "Sales log for buyers (2022/23)",
href: download_22_23_sales_form_path,
- metadata: "PDF, 397 KB, 5 pages",
+ metadata: file_type_size_and_pages("2022_23_sales_paper_form.pdf", number_of_pages: 5),
+ },
+ {
+ name: "Sales bulk upload template (2022/23)",
+ href: download_22_23_sales_bulk_upload_template_path,
+ metadata: file_type_size_and_pages("bulk-upload-sales-template-2022-23.xlsx"),
+ },
+ {
+ name: "Sales bulk upload specification (2022/23)",
+ href: download_22_23_sales_bulk_upload_specification_path,
+ metadata: file_type_size_and_pages("bulk-upload-sales-template-2022-23.xlsx"),
},
]) %>
diff --git a/config/routes.rb b/config/routes.rb
index f007317dc..9dd9b7325 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"
@@ -46,6 +47,12 @@ Rails.application.routes.draw do
get "/download-23-24-sales-form", to: "start#download_23_24_sales_form"
get "/download-22-23-sales-form", to: "start#download_22_23_sales_form"
+ get "/download-23-24-sales-bulk-upload-template", to: "start#download_23_24_sales_bulk_upload_template"
+ get "/download-23-24-sales-bulk-upload-legacy-template", to: "start#download_23_24_sales_bulk_upload_legacy_template"
+ get "/download-23-24-sales-bulk-upload-specification", to: "start#download_23_24_sales_bulk_upload_specification"
+
+ get "/download-22-23-sales-bulk-upload-template", to: "start#download_22_23_sales_bulk_upload_template"
+ get "/download-22-23-sales-bulk-upload-specification", to: "start#download_22_23_sales_bulk_upload_specification"
resource :account, only: %i[show edit], controller: "users" do
get "edit/password", to: "users#edit_password"
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
new file mode 100644
index 000000000..531775d00
Binary files /dev/null and b/public/files/bulk-upload-sales-legacy-template-2023-24.xlsx differ
diff --git a/public/files/bulk-upload-sales-specification-2022-23.xlsx b/public/files/bulk-upload-sales-specification-2022-23.xlsx
index b1e825fbb..5620f1d1c 100644
Binary files a/public/files/bulk-upload-sales-specification-2022-23.xlsx and b/public/files/bulk-upload-sales-specification-2022-23.xlsx differ
diff --git a/public/files/bulk-upload-sales-specification-2023-24.xlsx b/public/files/bulk-upload-sales-specification-2023-24.xlsx
index a7122e397..9d1d4be62 100644
Binary files a/public/files/bulk-upload-sales-specification-2023-24.xlsx and b/public/files/bulk-upload-sales-specification-2023-24.xlsx differ
diff --git a/public/files/bulk-upload-sales-template-2022-23.xlsx b/public/files/bulk-upload-sales-template-2022-23.xlsx
index 73c9f829c..2500a7bae 100644
Binary files a/public/files/bulk-upload-sales-template-2022-23.xlsx and b/public/files/bulk-upload-sales-template-2022-23.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 de79ac6d6..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
diff --git a/spec/helpers/collection_resources_helper_spec.rb b/spec/helpers/collection_resources_helper_spec.rb
new file mode 100644
index 000000000..0c87188d7
--- /dev/null
+++ b/spec/helpers/collection_resources_helper_spec.rb
@@ -0,0 +1,20 @@
+require "rails_helper"
+
+RSpec.describe CollectionResourcesHelper do
+ let(:current_user) { create(:user, :data_coordinator) }
+ let(:user) { create(:user, :data_coordinator) }
+
+ describe "when displaying file metadata" do
+ context "with pages" do
+ it "returns correct metadata" do
+ expect(file_type_size_and_pages("2023_24_lettings_paper_form.pdf", number_of_pages: 8)).to eq("PDF, 286 KB, 8 pages")
+ end
+ end
+
+ context "without pages" do
+ it "returns correct metadata" do
+ expect(file_type_size_and_pages("bulk-upload-lettings-template-2023-24.xlsx")).to eq("Microsoft Excel, 15 KB")
+ end
+ end
+ end
+end