diff --git a/app/models/form/sales/pages/privacy_notice.rb b/app/models/form/sales/pages/privacy_notice.rb new file mode 100644 index 000000000..03777e1f9 --- /dev/null +++ b/app/models/form/sales/pages/privacy_notice.rb @@ -0,0 +1,15 @@ +class Form::Sales::Pages::PrivacyNotice < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "privacy_notice" + @header = "Department for Levelling Up, Housing and Communities privacy notice" + @description = "Make sure that the buyer has seen the Department for Levelling Up, Housing and Communities (DLUHC) privacy notice before completing this log" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::PrivacyNotice.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/questions/privacy_notice.rb b/app/models/form/sales/questions/privacy_notice.rb new file mode 100644 index 000000000..d4e6016de --- /dev/null +++ b/app/models/form/sales/questions/privacy_notice.rb @@ -0,0 +1,17 @@ +class Form::Sales::Questions::PrivacyNotice < ::Form::Question + def initialize(id, hsh, page) + super + @id = "privacynotice" + @check_answer_label = "Buyer has seen the privacy notice?" + @header = "Declaration" + @guidance_partial = "test" + @type = "checkbox" + @hint_text = "" + @page = page + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "privacynotice" => { "value" => "The tenant has seen the DLUHC privacy notice" }, + }.freeze +end diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index 93d084332..e478a6be5 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/app/models/form/sales/subsections/household_characteristics.rb @@ -10,6 +10,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection def pages @pages ||= [ Form::Sales::Pages::BuyerInterview.new(nil, nil, self), + Form::Sales::Pages::PrivacyNotice.new(nil, nil, self), Form::Sales::Pages::Age1.new(nil, nil, self), Form::Sales::Pages::GenderIdentity1.new(nil, nil, self), Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self), diff --git a/db/migrate/20221004095132_add_privacy_notice_to_sales_log.rb b/db/migrate/20221004095132_add_privacy_notice_to_sales_log.rb new file mode 100644 index 000000000..f60b00823 --- /dev/null +++ b/db/migrate/20221004095132_add_privacy_notice_to_sales_log.rb @@ -0,0 +1,7 @@ +class AddPrivacyNoticeToSalesLog < ActiveRecord::Migration[7.0] + def change + change_table :sales_logs, bulk: true do |t| + t.column :privacynotice, :int + end + end +end diff --git a/db/schema.rb b/db/schema.rb index b30200da0..76cac362e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2022_10_03_150610) do +ActiveRecord::Schema[7.0].define(version: 2022_10_04_095132) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -351,6 +351,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_03_150610) do t.integer "noint" t.integer "buy2livein" t.integer "ecstat2" + t.integer "privacynotice" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id" diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb index 364895cc8..3e424f094 100644 --- a/spec/models/form/sales/subsections/household_characteristics_spec.rb +++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb @@ -15,6 +15,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model expect(household_characteristics.pages.map(&:id)).to eq( %w[ buyer_interview + privacy_notice buyer_1_age buyer_1_gender_identity buyer_1_live_in_property