Browse Source

feat: core functionality

pull/931/head
natdeanlewissoftwire 4 years ago
parent
commit
fd9372f069
  1. 15
      app/models/form/sales/pages/privacy_notice.rb
  2. 17
      app/models/form/sales/questions/privacy_notice.rb
  3. 1
      app/models/form/sales/subsections/household_characteristics.rb
  4. 7
      db/migrate/20221004095132_add_privacy_notice_to_sales_log.rb
  5. 3
      db/schema.rb
  6. 1
      spec/models/form/sales/subsections/household_characteristics_spec.rb

15
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

17
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

1
app/models/form/sales/subsections/household_characteristics.rb

@ -10,6 +10,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
def pages def pages
@pages ||= [ @pages ||= [
Form::Sales::Pages::BuyerInterview.new(nil, nil, self), 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::Age1.new(nil, nil, self),
Form::Sales::Pages::GenderIdentity1.new(nil, nil, self), Form::Sales::Pages::GenderIdentity1.new(nil, nil, self),
Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self), Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self),

7
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

3
db/schema.rb

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # 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 # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -351,6 +351,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_03_150610) do
t.integer "noint" t.integer "noint"
t.integer "buy2livein" t.integer "buy2livein"
t.integer "ecstat2" t.integer "ecstat2"
t.integer "privacynotice"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" 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 ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"

1
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( expect(household_characteristics.pages.map(&:id)).to eq(
%w[ %w[
buyer_interview buyer_interview
privacy_notice
buyer_1_age buyer_1_age
buyer_1_gender_identity buyer_1_gender_identity
buyer_1_live_in_property buyer_1_live_in_property

Loading…
Cancel
Save