Browse Source

change field to correct unitletas

pull/95/head
magicmilo 3 years ago
parent
commit
a923e14969
  1. 2
      app/admin/case_logs.rb
  2. 9
      app/constants/db_enums.rb
  3. 1
      app/models/case_log.rb
  4. 2
      config/forms/2021_2022.json
  5. 15
      db/migrate/20211124152204_change_recently_let_as_to_enum.rb
  6. 4
      db/schema.rb
  7. 4
      spec/fixtures/complete_case_log.json

2
app/admin/case_logs.rb

@ -2,7 +2,7 @@ ActiveAdmin.register CaseLog do
# See permitted parameters documentation: # See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
permit_params do permit_params do
permitted = %i[status tenant_code age1 sex1 tenant_ethnic_group tenant_nationality previous_housing_situation armedforces ecstat1 other_hhmemb relat2 age2 sex2 ecstat2 relat3 age3 sex3 ecstat3 relat4 age4 sex4 ecstat4 relat5 age5 sex5 ecstat5 relat6 age6 sex6 ecstat6 relat7 age7 person_7_gender ecstat7 relat8 age8 sex8 ecstat8 homelessness reason benefit_cap_spare_room_subsidy armed_forces_active armed_forces_injured medical_conditions pregnancy accessibility_requirements condition_effects tenancy_code tenancy_start_date starter_tenancy fixed_term_tenancy tenancy_type letting_type letting_provider la previous_postcode property_relet property_vacancy_reason property_reference property_unit_type property_building_type property_number_of_bedrooms property_void_date majorrepairs mrcdate property_number_of_times_relet property_wheelchair_accessible net_income net_income_frequency net_income_uc_proportion hb rent_frequency basic_rent service_charge personal_service_charge support_charge total_charge tshortfall time_lived_in_la time_on_la_waiting_list prevloc property_postcode reasonable_preference reasonable_preference_reason cbl_letting chr_letting cap_letting hbrentshortfall other_reason 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 age1 sex1 tenant_ethnic_group tenant_nationality previous_housing_situation armedforces ecstat1 other_hhmemb relat2 age2 sex2 ecstat2 relat3 age3 sex3 ecstat3 relat4 age4 sex4 ecstat4 relat5 age5 sex5 ecstat5 relat6 age6 sex6 ecstat6 relat7 age7 person_7_gender ecstat7 relat8 age8 sex8 ecstat8 homelessness reason benefit_cap_spare_room_subsidy armed_forces_active armed_forces_injured medical_conditions pregnancy accessibility_requirements condition_effects tenancy_code tenancy_start_date starter_tenancy fixed_term_tenancy tenancy_type letting_type letting_provider la previous_postcode property_relet property_vacancy_reason property_reference property_unit_type property_building_type property_number_of_bedrooms property_void_date majorrepairs mrcdate property_wheelchair_accessible net_income net_income_frequency net_income_uc_proportion hb rent_frequency basic_rent service_charge personal_service_charge support_charge total_charge tshortfall time_lived_in_la time_on_la_waiting_list prevloc property_postcode reasonable_preference reasonable_preference_reason cbl_letting chr_letting cap_letting hbrentshortfall other_reason 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 permitted
end end

9
app/constants/db_enums.rb

@ -10,6 +10,15 @@ module DbEnums
} }
end end
def self.unitletas
{
"Social rent basis" => 1,
"Affordable rent basis" => 2,
"Intermediate rent basis" => 4,
"Do not know" => 3,
}
end
def self.ecstat def self.ecstat
{ {
"Part-time - Less than 30 hours" => 2, "Part-time - Less than 30 hours" => 2,

1
app/models/case_log.rb

@ -111,6 +111,7 @@ class CaseLog < ApplicationRecord
enum property_relet: DbEnums.polar, _suffix: true enum property_relet: DbEnums.polar, _suffix: true
enum armedforces: DbEnums.armed_forces, _suffix: true enum armedforces: DbEnums.armed_forces, _suffix: true
enum first_time_property_let_as_social_housing: DbEnums.polar, _suffix: true enum first_time_property_let_as_social_housing: DbEnums.polar, _suffix: true
enum unitletas: DbEnums.unitletas, _suffix: true
AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze
OPTIONAL_FIELDS = %w[do_you_know_the_postcode do_you_know_the_local_authority].freeze OPTIONAL_FIELDS = %w[do_you_know_the_postcode do_you_know_the_local_authority].freeze

2
config/forms/2021_2022.json

@ -1518,7 +1518,7 @@
}, },
"depends_on": { "tenant_same_property_renewal": "No"} "depends_on": { "tenant_same_property_renewal": "No"}
}, },
"type_property_most_recently_let_as": { "unitletas": {
"header": "", "header": "",
"description": "", "description": "",
"questions": { "questions": {

15
db/migrate/20211124152204_change_recently_let_as_to_enum.rb

@ -0,0 +1,15 @@
class ChangeRecentlyLetAsToEnum < ActiveRecord::Migration[6.1]
def up
change_table :case_logs, bulk: true do |t|
t.remove :type_property_most_recently_let_as
t.column :unitletas, :int
end
end
def down
change_table :case_logs, bulk: true do |t|
t.remove :unitletas
t.column :type_property_most_recently_let_as, :string
end
end
end

4
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.define(version: 2021_11_19_120910) do ActiveRecord::Schema.define(version: 2021_11_24_152204) 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"
@ -167,8 +167,8 @@ ActiveRecord::Schema.define(version: 2021_11_19_120910) do
t.string "property_postcode" t.string "property_postcode"
t.integer "first_time_property_let_as_social_housing" t.integer "first_time_property_let_as_social_housing"
t.string "why_dont_you_know_la" t.string "why_dont_you_know_la"
t.string "type_property_most_recently_let_as"
t.string "builtype" t.string "builtype"
t.integer "unitletas"
t.index ["discarded_at"], name: "index_case_logs_on_discarded_at" t.index ["discarded_at"], name: "index_case_logs_on_discarded_at"
end end

4
spec/fixtures/complete_case_log.json vendored

@ -1,7 +1,6 @@
{ {
"case_log": { "case_log": {
"tenant_code": "T657", "tenant_code": "T657",
"tenanceother": "",
"age1": 35, "age1": 35,
"sex1": "Female", "sex1": "Female",
"ethnic": "White: English/Scottish/Welsh/Northern Irish/British", "ethnic": "White: English/Scottish/Welsh/Northern Irish/British",
@ -139,8 +138,7 @@
"ppostc2": "w3", "ppostc2": "w3",
"why_dont_you_know_la": "Forgot", "why_dont_you_know_la": "Forgot",
"first_time_property_let_as_social_housing": "Yes", "first_time_property_let_as_social_housing": "Yes",
"type_property_most_recently_let_as": "Affordable rent basis", "unitletas": "Affordable rent basis",
"property_number_of_times_relet_social_let": 1,
"builtype": "Purpose built", "builtype": "Purpose built",
"property_wheelchair_accessible": "Yes", "property_wheelchair_accessible": "Yes",
"void_or_renewal_date": "05/05/2020", "void_or_renewal_date": "05/05/2020",

Loading…
Cancel
Save