From 93efd969e51f28e6ae81e1b95fd322dbed3abd41 Mon Sep 17 00:00:00 2001
From: Daniel Baark <5101747+baarkerlounger@users.noreply.github.com>
Date: Wed, 17 Nov 2021 08:56:47 +0000
Subject: [PATCH] Form changes and small fixes (#96)
* Remove tenancy code question
* Rubocop
* Fix spec
* Use Gov component gem header
---
app/models/bulk_upload.rb | 10 ++++----
app/views/layouts/application.html.erb | 25 +++++---------------
config/forms/2021_2022.json | 12 ----------
db/migrate/20211116102527_change_datetime.rb | 11 ++++++++-
db/schema.rb | 4 ++--
5 files changed, 24 insertions(+), 38 deletions(-)
diff --git a/app/models/bulk_upload.rb b/app/models/bulk_upload.rb
index f546ea56d..dcab1753f 100644
--- a/app/models/bulk_upload.rb
+++ b/app/models/bulk_upload.rb
@@ -26,12 +26,14 @@ class BulkUpload
else
data_range = FIRST_DATA_ROW..last_row
data_range.map do |row_num|
- case_log = CaseLog.create
+ case_log = CaseLog.create!
map_row(sheet.row(row_num)).each do |attr_key, attr_val|
- begin
- case_log.update_attribute(attr_key, attr_val)
- rescue ArgumentError
+ update = case_log.update(attr_key => attr_val)
+ unless update
+ # TODO: determine what to do when a bulk upload contains field values that don't pass validations
end
+ rescue ArgumentError
+ # TODO: determine what we want to do when bulk upload contains totally invalid data for a field.
end
end
end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 7ea45b6e4..ad52856b9 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -33,25 +33,12 @@
Skip to main content
diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json
index 885d4dadf..b0ac1a524 100644
--- a/config/forms/2021_2022.json
+++ b/config/forms/2021_2022.json
@@ -1028,18 +1028,6 @@
"tenancy_information": {
"label": "Tenancy information",
"pages": {
- "tenancy_code": {
- "header": "",
- "description": "",
- "questions": {
- "tenancy_code": {
- "check_answer_label": "What is the tenancy code?",
- "header": "What is the tenancy code?",
- "hint_text": "",
- "type": "text"
- }
- }
- },
"starter_tenancy": {
"header": "",
"description": "",
diff --git a/db/migrate/20211116102527_change_datetime.rb b/db/migrate/20211116102527_change_datetime.rb
index f3b78282b..10a9c581f 100644
--- a/db/migrate/20211116102527_change_datetime.rb
+++ b/db/migrate/20211116102527_change_datetime.rb
@@ -1,5 +1,5 @@
class ChangeDatetime < ActiveRecord::Migration[6.1]
- def change
+ def up
change_table :case_logs, bulk: true do |t|
t.remove :sale_completion_date
t.column :sale_completion_date, :datetime
@@ -7,4 +7,13 @@ class ChangeDatetime < ActiveRecord::Migration[6.1]
t.column :startdate, :datetime
end
end
+
+ def down
+ change_table :case_logs, bulk: true do |t|
+ t.remove :sale_completion_date
+ t.column :sale_completion_date, :string
+ t.remove :startdate
+ t.column :startdate, :string
+ end
+ end
end
diff --git a/db/schema.rb b/db/schema.rb
index fa2839c20..b011b0ce8 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -121,6 +121,8 @@ ActiveRecord::Schema.define(version: 2021_11_16_102527) do
t.integer "rp_dontknow"
t.datetime "discarded_at"
t.string "tenancyother"
+ t.integer "override_net_income_validation"
+ t.string "net_income_known"
t.string "gdpr_acceptance"
t.string "gdpr_declined"
t.string "property_owner_organisation"
@@ -131,8 +133,6 @@ ActiveRecord::Schema.define(version: 2021_11_16_102527) do
t.string "intermediate_rent_product_name"
t.string "needs_type"
t.string "purchaser_code"
- t.integer "override_net_income_validation"
- t.string "net_income_known"
t.integer "reason"
t.string "propcode"
t.integer "majorrepairs"