diff --git a/app/admin/case_logs.rb b/app/admin/case_logs.rb index cd303787e..5b5861e1b 100644 --- a/app/admin/case_logs.rb +++ b/app/admin/case_logs.rb @@ -1,9 +1,8 @@ ActiveAdmin.register CaseLog do - # See permitted parameters documentation: # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters permit_params do - permitted = [:status, :tenant_code, :person_1_age, :person_1_gender, :tenant_ethnic_group, :tenant_nationality, :previous_housing_situation, :armed_forces, :person_1_economic_status, :household_number_of_other_members, :person_2_relationship, :person_2_age, :person_2_gender, :person_2_economic_status, :person_3_relationship, :person_3_age, :person_3_gender, :person_3_economic_status, :person_4_relationship, :person_4_age, :person_4_gender, :person_4_economic_status, :person_5_relationship, :person_5_age, :person_5_gender, :person_5_economic_status, :person_6_relationship, :person_6_age, :person_6_gender, :person_6_economic_status, :person_7_relationship, :person_7_age, :person_7_gender, :person_7_economic_status, :person_8_relationship, :person_8_age, :person_8_gender, :person_8_economic_status, :homelessness, :reason_for_leaving_last_settled_home, :benefit_cap_spare_room_subsidy, :armed_forces_active, :armed_forces_injured, :armed_forces_partner, :medical_conditions, :pregnancy, :accessibility_requirements, :condition_effects, :tenancy_code, :tenancy_start_date, :starter_tenancy, :fixed_term_tenancy, :tenancy_type, :letting_type, :letting_provider, :property_location, :previous_postcode, :property_relet, :property_vacancy_reason, :property_reference, :property_unit_type, :property_building_type, :property_number_of_bedrooms, :property_void_date, :property_major_repairs, :property_major_repairs_date, :property_number_of_times_relet, :property_wheelchair_accessible, :net_income, :net_income_frequency, :net_income_uc_proportion, :housing_benefit, :rent_frequency, :basic_rent, :service_charge, :personal_service_charge, :support_charge, :total_charge, :outstanding_amount, :time_lived_in_la, :time_on_la_waiting_list, :previous_la, :property_postcode, :reasonable_preference, :reasonable_preference_reason, :cbl_letting, :chr_letting, :cap_letting, :outstanding_rent_or_charges, :other_reason_for_leaving_last_settled_home, :accessibility_requirements_fully_wheelchair_accessible_housing, :accessibility_requirements_wheelchair_access_to_essential_rooms, :accessibility_requirements_level_access_housing, :accessibility_requirements_other_disability_requirements, :accessibility_requirements_no_disability_requirements, :accessibility_requirements_do_not_know, :accessibility_requirements_prefer_not_to_say, :condition_effects_vision, :condition_effects_hearing, :condition_effects_mobility, :condition_effects_dexterity, :condition_effects_stamina, :condition_effects_learning, :condition_effects_memory, :condition_effects_mental_health, :condition_effects_social_or_behavioral, :condition_effects_other, :condition_effects_prefer_not_to_say, :reasonable_preference_reason_homeless, :reasonable_preference_reason_unsatisfactory_housing, :reasonable_preference_reason_medical_grounds, :reasonable_preference_reason_avoid_hardship, :reasonable_preference_reason_do_not_know, :other_tenancy_type, :override_net_income_validation, :net_income_known] + permitted = %i[status tenant_code person_1_age person_1_gender tenant_ethnic_group tenant_nationality previous_housing_situation armed_forces person_1_economic_status household_number_of_other_members person_2_relationship person_2_age person_2_gender person_2_economic_status person_3_relationship person_3_age person_3_gender person_3_economic_status person_4_relationship person_4_age person_4_gender person_4_economic_status person_5_relationship person_5_age person_5_gender person_5_economic_status person_6_relationship person_6_age person_6_gender person_6_economic_status person_7_relationship person_7_age person_7_gender person_7_economic_status person_8_relationship person_8_age person_8_gender person_8_economic_status homelessness reason_for_leaving_last_settled_home benefit_cap_spare_room_subsidy armed_forces_active armed_forces_injured armed_forces_partner medical_conditions pregnancy accessibility_requirements condition_effects tenancy_code tenancy_start_date starter_tenancy fixed_term_tenancy tenancy_type letting_type letting_provider property_location previous_postcode property_relet property_vacancy_reason property_reference property_unit_type property_building_type property_number_of_bedrooms property_void_date property_major_repairs property_major_repairs_date property_number_of_times_relet property_wheelchair_accessible net_income net_income_frequency net_income_uc_proportion housing_benefit rent_frequency basic_rent service_charge personal_service_charge support_charge total_charge outstanding_amount time_lived_in_la time_on_la_waiting_list previous_la property_postcode reasonable_preference reasonable_preference_reason cbl_letting chr_letting cap_letting outstanding_rent_or_charges other_reason_for_leaving_last_settled_home accessibility_requirements_fully_wheelchair_accessible_housing accessibility_requirements_wheelchair_access_to_essential_rooms accessibility_requirements_level_access_housing accessibility_requirements_other_disability_requirements accessibility_requirements_no_disability_requirements accessibility_requirements_do_not_know accessibility_requirements_prefer_not_to_say condition_effects_vision condition_effects_hearing condition_effects_mobility condition_effects_dexterity condition_effects_stamina condition_effects_learning condition_effects_memory condition_effects_mental_health condition_effects_social_or_behavioral condition_effects_other condition_effects_prefer_not_to_say reasonable_preference_reason_homeless reasonable_preference_reason_unsatisfactory_housing reasonable_preference_reason_medical_grounds reasonable_preference_reason_avoid_hardship reasonable_preference_reason_do_not_know other_tenancy_type override_net_income_validation net_income_known] permitted end diff --git a/app/helpers/check_answers_helper.rb b/app/helpers/check_answers_helper.rb index 3e59de811..1cc1bc65e 100644 --- a/app/helpers/check_answers_helper.rb +++ b/app/helpers/check_answers_helper.rb @@ -56,6 +56,8 @@ module CheckAnswersHelper operator = condition[/[<>=]+/].to_sym operand = condition[/\d+/].to_i case_log[question_key].blank? || !case_log[question_key].send(operator, operand) + when "text" + case_log[question_key].blank? || !condition.include?(case_log[question_key]) when "radio" case_log[question_key].blank? || !condition.include?(case_log[question_key]) else diff --git a/app/views/form/_select_question.html.erb b/app/views/form/_select_question.html.erb new file mode 100644 index 000000000..6f41b6b35 --- /dev/null +++ b/app/views/form/_select_question.html.erb @@ -0,0 +1,11 @@ + +<%= answers = question["answer_options"].map {|key, value| OpenStruct.new(id:key, name: value)} + f.govuk_collection_select question_key, + answers, + :name, + :name, + label: { text: question["header"]}, + hint: { text: question["hint_text"] } + %> + + diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index cb74d6edc..406f5a69f 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -3,6 +3,181 @@ "start_year": 2021, "end_year": 2022, "sections": { + "about_this_log": { + "label": "About this log", + "subsections": { + "about_this_log": { + "label": "About this log", + "pages": { + "gdpr_acceptance": { + "header": "DLUHC Privacy Notice Acceptance", + "description": "", + "questions": { + "gdpr_acceptance": { + "check_answer_label": "GDPR acceptance", + "header": "Has the tenant or buyer seen the DLUHC privacy notice?", + "hint_text": "", + "type": "radio", + "answer_options": { + "0": "Yes", + "1": "No" + } + } + }, + "conditional_route_to": { + "organisation_details": { "gdpr_acceptance": "Yes" } + }, + "default_next_page": "gdpr_declined" + }, + "gdpr_declined": { + "header": "You cannot use this service", + "hint_text": "", + "description": "We cannot accept data about a tenant or buyer unless they’ve seen the DLUHC privacy notice.", + "questions": { + + }, + "default_next_page" : "check_answers" + }, + "organisation_details": { + "header": "About this log", + "description": "Organisation Details", + "questions": { + "property_owner_organisation": { + "check_answer_label": "", + "header": "Which organisation owns this property?", + "hint_text": "", + "type": "radio", + "answer_options": { + "0": "A", + "1": "B" + } + }, + "property_manager_organisation": { + "check_answer_label": "", + "header": "Which organisation manages this property?", + "hint_text": "", + "type": "radio", + "answer_options": { + "0": "A", + "1": "B" + } + } + } + }, + "sale_or_letting": { + "header": "About this log", + "description": "Is this a sale or a letting?", + "questions": { + "sale_or_letting": { + "check_answer_label": "", + "header": "Is this a sale or a letting?", + "hint_text": "", + "type": "radio", + "answer_options": { + "0": "Sale", + "1": "Letting" + } + } + }, + "conditional_route_to": { + "tenant_same_property_renewal": { "sale_or_letting": "Letting" } + }, + "default_next_page" : "check_answers" + }, + "tenant_same_property_renewal": { + "header": "About this log", + "description": "Is this a renewal to the same tenant in the same property?", + "questions": { + "tenant_same_property_renewal": { + "check_answer_label": "", + "header": "Is this a renewal to the same tenant in the same property?", + "hint_text": "", + "type": "radio", + "answer_options": { + "0": "Yes", + "1": "No" + } + } + } + }, + "tenancy_start_date": { + "header": "About this log", + "description": "", + "questions": { + "tenancy_start_date": { + "check_answer_label": "When is the tenancy start date?", + "header": "What is the tenancy start date?", + "hint_text": "For example, 27 3 2007", + "type": "date" + } + } + }, + "letting_type": { + "header": "About this log", + "description": "", + "questions": { + "rent_type": { + "check_answer_label": "What is the rent type?", + "header": "What is the rent type?", + "hint_text": "", + "type": "select", + "answer_options": { + "0": "Social Rent", + "1": "Affordable Rent", + "2": "London Affordable Rent", + "3": "Rent To Buy", + "4": "London Living Rent", + "5": "Other Intermediate Rent Product" + }, + "conditional_for": { + "intermediate_rent_product_name": ["Other Intermediate Rent Product"] + } + }, + "intermediate_rent_product_name": { + "check_answer_label": "Enter the product name", + "header": "What is intermediate rent product name?", + "type": "text" + }, + "needs_type": { + "check_answer_label": "What is the needs type?", + "header": "What is the needs type?", + "hint_text": "", + "type": "select", + "answer_options": { + "0": "Supported Housing", + "1": "General Needs" + } + } + } + }, + "sale_completion_date": { + "header": "About this log", + "description": "", + "questions": { + "sale_completion_date": { + "check_answer_label": "What is the sale completion date?", + "header": "What is the sale completion date?", + "hint_text": "For example, 27 3 2007", + "type": "date" + } + } + }, + "purchaser_code": { + "header": "About this log", + "description": "", + "questions": { + "purchaser_code": { + "check_answer_label": "What is the purchaser code?", + "header": "What is the purchaser code?", + "hint_text": "", + "type": "text" + } + } + } + } + } + } + }, "household": { "label": "About the household", "subsections": { diff --git a/config/initializers/active_admin.rb b/config/initializers/active_admin.rb index 4ef658194..5afdcdc12 100644 --- a/config/initializers/active_admin.rb +++ b/config/initializers/active_admin.rb @@ -124,7 +124,7 @@ ActiveAdmin.setup do |config| # This allows your users to comment on any resource registered with Active Admin. # # You can completely disable comments: - config.comments = false + config.comments = false # # You can change the name under which comments are registered: # config.comments_registration_name = 'AdminComment' @@ -157,7 +157,7 @@ ActiveAdmin.setup do |config| # You can exclude possibly sensitive model attributes from being displayed, # added to forms, or exported by default by ActiveAdmin # - config.filter_attributes = [:encrypted_password, :password, :password_confirmation] + config.filter_attributes = %i[encrypted_password password password_confirmation] # == Localize Date/Time Format # diff --git a/db/migrate/20211102100820_add_about_this_log_readable_columns.rb b/db/migrate/20211102100820_add_about_this_log_readable_columns.rb new file mode 100644 index 000000000..b451af20e --- /dev/null +++ b/db/migrate/20211102100820_add_about_this_log_readable_columns.rb @@ -0,0 +1,17 @@ +class AddAboutThisLogReadableColumns < ActiveRecord::Migration[6.1] + def change + change_table :case_logs, bulk: true do |t| + t.column :gdpr_acceptance, :string + t.column :gdpr_declined, :string + t.column :property_owner_organisation, :string + t.column :property_manager_organisation, :string + t.column :sale_or_letting, :string + t.column :tenant_same_property_renewal, :string + t.column :rent_type, :string + t.column :intermediate_rent_product_name, :string + t.column :needs_type, :string + t.column :sale_completion_date, :string + t.column :purchaser_code, :string + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 7f75e5e87..ddd456c43 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.define(version: 2021_10_28_095000) do +ActiveRecord::Schema.define(version: 2021_11_02_100820) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -133,6 +133,17 @@ ActiveRecord::Schema.define(version: 2021_10_28_095000) do t.boolean "reasonable_preference_reason_do_not_know" t.datetime "discarded_at" t.string "other_tenancy_type" + t.string "gdpr_acceptance" + t.string "gdpr_declined" + t.string "property_owner_organisation" + t.string "property_manager_organisation" + t.string "sale_or_letting" + t.string "tenant_same_property_renewal" + t.string "rent_type" + t.string "intermediate_rent_product_name" + t.string "needs_type" + t.string "sale_completion_date" + t.string "purchaser_code" t.boolean "override_net_income_validation" t.string "net_income_known" t.index ["discarded_at"], name: "index_case_logs_on_discarded_at" diff --git a/spec/fixtures/complete_case_log.json b/spec/fixtures/complete_case_log.json index 45e402f4e..9c84a7993 100644 --- a/spec/fixtures/complete_case_log.json +++ b/spec/fixtures/complete_case_log.json @@ -113,6 +113,18 @@ "reasonable_preference_reason_unsatisfactory_housing": false, "reasonable_preference_reason_medical_grounds": false, "reasonable_preference_reason_avoid_hardship": false, - "reasonable_preference_reason_do_not_know": true + "reasonable_preference_reason_do_not_know": true, + "other_tenancy_type": "", + "gdpr_acceptance": "", + "gdpr_declined": "", + "property_owner_organisation": "", + "property_manager_organisation": "", + "sale_or_letting": "", + "tenant_same_property_renewal": "", + "rent_type": "", + "intermediate_rent_product_name": "", + "needs_type": "", + "sale_completion_date" : "", + "purchaser_code": "" } } diff --git a/spec/fixtures/forms/test_aboutthislog.json b/spec/fixtures/forms/test_aboutthislog.json new file mode 100644 index 000000000..2cfd8ff26 --- /dev/null +++ b/spec/fixtures/forms/test_aboutthislog.json @@ -0,0 +1,180 @@ +{ + "form_type": "lettings", + "sections": { + "about_this_log": { + "label": "About this log", + "subsections": { + "about_this_log": { + "label": "About this log", + "pages": { + "gdpr_acceptance": { + "header": "DLUHC Privacy Notice Acceptance", + "description": "", + "questions": { + "gdpr_acceptance": { + "check_answer_label": "GDPR acceptance", + "header": "Has the tenant or buyer seen the DLUHC privacy notice?", + "hint_text": "", + "type": "radio", + "answer_options": { + "0": "Yes", + "1": "No" + } + } + }, + "conditional_route_to": { + "organisation_details": { "gdpr_acceptance": "Yes" } + }, + "default_next_page": "gdpr_declined" + }, + "gdpr_declined": { + "header": "You cannot use this service", + "hint_text": "", + "description": "We cannot accept data about a tenant or buyer unless they’ve seen the DLUHC privacy notice.", + "questions": { + + }, + "default_next_page" : "check_answers" + }, + "organisation_details": { + "header": "About this log", + "description": "Organisation Details", + "questions": { + "property_owner_organisation": { + "check_answer_label": "", + "header": "Which organisation owns this property?", + "hint_text": "", + "type": "radio", + "answer_options": { + "0": "A", + "1": "B" + } + }, + "property_manager_organisation": { + "check_answer_label": "", + "header": "Which organisation manages this property?", + "hint_text": "", + "type": "radio", + "answer_options": { + "0": "A", + "1": "B" + } + } + } + }, + "sale_or_letting": { + "header": "About this log", + "description": "Is this a sale or a letting?", + "questions": { + "sale_or_letting": { + "check_answer_label": "", + "header": "Is this a sale or a letting?", + "hint_text": "", + "type": "radio", + "answer_options": { + "0": "Sale", + "1": "Letting" + } + } + }, + "conditional_route_to": { + "tenant_same_property_renewal": { "sale_or_letting": "Letting" } + }, + "default_next_page" : "check_answers" + }, + "tenant_same_property_renewal": { + "header": "About this log", + "description": "Is this a renewal to the same tenant in the same property?", + "questions": { + "tenant_same_property_renewal": { + "check_answer_label": "", + "header": "Is this a renewal to the same tenant in the same property?", + "hint_text": "", + "type": "radio", + "answer_options": { + "0": "Yes", + "1": "No" + } + } + } + }, + "tenancy_start_date": { + "header": "About this log", + "description": "", + "questions": { + "tenancy_start_date": { + "check_answer_label": "When is the tenancy start date?", + "header": "What is the tenancy start date?", + "hint_text": "For example, 27 3 2007", + "type": "date" + } + } + }, + "letting_type": { + "header": "About this log", + "description": "", + "questions": { + "rent_type": { + "check_answer_label": "What is the rent type?", + "header": "What is the rent type?", + "hint_text": "", + "type": "select", + "answer_options": { + "0": "Social Rent", + "1": "Affordable Rent", + "2": "London Affordable Rent", + "3": "Rent To Buy", + "4": "London Living Rent", + "5": "Other Intermediate Rent Product" + }, + "conditional_for": { + "intermediate_rent_product_name": ["Other Intermediate Rent Product"] + } + }, + "intermediate_rent_product_name": { + "check_answer_label": "Enter the product name", + "header": "What is intermediate rent product name?", + "type": "text" + }, + "needs_type": { + "check_answer_label": "What is the needs type?", + "header": "What is the needs type?", + "hint_text": "", + "type": "select", + "answer_options": { + "0": "Supported Housing", + "1": "General Needs" + } + } + } + }, + "sale_completion_date": { + "header": "About this log", + "description": "", + "questions": { + "sale_completion_date": { + "check_answer_label": "What is the sale completion date?", + "header": "What is the sale completion date?", + "hint_text": "For example, 27 3 2007", + "type": "date" + } + } + }, + "purchaser_code": { + "header": "About this log", + "description": "", + "questions": { + "purchaser_code": { + "check_answer_label": "What is the purchaser code?", + "header": "What is the purchaser code?", + "hint_text": "", + "type": "text" + } + } + } + } + } + } + } + } +} diff --git a/spec/helpers/check_answers_helper_spec.rb b/spec/helpers/check_answers_helper_spec.rb index 3eae2227c..5ac16b2bd 100644 --- a/spec/helpers/check_answers_helper_spec.rb +++ b/spec/helpers/check_answers_helper_spec.rb @@ -102,7 +102,7 @@ RSpec.describe CheckAnswersHelper do end it "raises an error" do - allow_any_instance_of(Form).to receive(:pages_for_subsection).and_return(unimplemented_conditional) + allow_any_instance_of(Form).to receive(:questions_for_page).and_return(unimplemented_conditional) expect { total_number_of_questions(subsection, case_log, form) }.to raise_error(RuntimeError, "Not implemented yet") end end