Browse Source

CLDC-2372 Update bulk upload resources (#1671)

* Reorder resources list

* Update sales 23/24 resources

* Update sales 22/23 resources

* Fix typo and add missing paths

* Change the wording

* feat: update files, add 22/23 lettings form to local storage and add collection resources helper

* feat: remove sales bu feature toggoe

* refactor: lint

* refactor: erblinting

* feat: add tests for helper

* feat: revert feature flag removal (will put in a separate PR)

* refactor: update matadata helper

---------

Co-authored-by: natdeanlewissoftwire <nat.dean-lewis@softwire.com>
pull/1676/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
6053eb18c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 48
      app/controllers/start_controller.rb
  2. 15
      app/helpers/collection_resources_helper.rb
  3. 61
      app/views/layouts/_collection_resources.html.erb
  4. 7
      config/routes.rb
  5. BIN
      public/files/2022_23_lettings_paper_form.pdf
  6. BIN
      public/files/bulk-upload-sales-legacy-template-2023-24.xlsx
  7. BIN
      public/files/bulk-upload-sales-specification-2022-23.xlsx
  8. BIN
      public/files/bulk-upload-sales-specification-2023-24.xlsx
  9. BIN
      public/files/bulk-upload-sales-template-2022-23.xlsx
  10. BIN
      public/files/bulk-upload-sales-template-2023-24.xlsx
  11. 20
      spec/helpers/collection_resources_helper_spec.rb

48
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

15
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

61
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"),
},
]) %>
<h3 class="govuk-heading-s">Sales 2023/24</h3>
<%= 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",
},
]) %>
<h3 class="govuk-heading-s">Sales 2023/24</h3>
<%= 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"),
},
]) %>
</div>

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

BIN
public/files/2022_23_lettings_paper_form.pdf

Binary file not shown.

BIN
public/files/bulk-upload-sales-legacy-template-2023-24.xlsx

Binary file not shown.

BIN
public/files/bulk-upload-sales-specification-2022-23.xlsx

Binary file not shown.

BIN
public/files/bulk-upload-sales-specification-2023-24.xlsx

Binary file not shown.

BIN
public/files/bulk-upload-sales-template-2022-23.xlsx

Binary file not shown.

BIN
public/files/bulk-upload-sales-template-2023-24.xlsx

Binary file not shown.

20
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
Loading…
Cancel
Save