Milo
3 years ago
committed by
GitHub
38 changed files with 1190 additions and 168 deletions
@ -0,0 +1,20 @@ |
|||||||
|
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 |
||||||
|
end |
||||||
|
|
||||||
|
index do |
||||||
|
selectable_column |
||||||
|
id_column |
||||||
|
column :created_at |
||||||
|
column :updated_at |
||||||
|
column :status |
||||||
|
column :tenant_code |
||||||
|
column :property_postcode |
||||||
|
actions |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,32 @@ |
|||||||
|
ActiveAdmin.register_page "Dashboard" do |
||||||
|
menu priority: 1, label: proc { I18n.t("active_admin.dashboard") } |
||||||
|
|
||||||
|
content title: proc { I18n.t("active_admin.dashboard") } do |
||||||
|
columns do |
||||||
|
column do |
||||||
|
panel "Recent Case Logs" do |
||||||
|
table_for CaseLog.order(updated_at: :desc).limit(10) do |
||||||
|
column :id |
||||||
|
column :created_at |
||||||
|
column :updated_at |
||||||
|
column :status |
||||||
|
column :tenant_code |
||||||
|
column :property_postcode |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
column do |
||||||
|
panel "Total case logs in progress" do |
||||||
|
para CaseLog.in_progress.size |
||||||
|
end |
||||||
|
panel "Total case logs completed" do |
||||||
|
para CaseLog.completed.size |
||||||
|
end |
||||||
|
panel "Total case logs completed" do |
||||||
|
pie_chart CaseLog.group(:status).size |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,7 @@ |
|||||||
|
// Load Active Admin's styles into Webpacker,
|
||||||
|
// see `active_admin.scss` for customization.
|
||||||
|
import "../stylesheets/active_admin"; |
||||||
|
|
||||||
|
import "@activeadmin/activeadmin"; |
||||||
|
|
||||||
|
import "chartkick/chart.js" |
@ -0,0 +1,2 @@ |
|||||||
|
/* Active Admin Print Stylesheet */ |
||||||
|
@import "~@activeadmin/activeadmin/src/scss/print"; |
@ -0,0 +1,17 @@ |
|||||||
|
// Sass variable overrides must be declared before loading up Active Admin's styles. |
||||||
|
// |
||||||
|
// To view the variables that Active Admin provides, take a look at |
||||||
|
// `app/assets/stylesheets/active_admin/mixins/_variables.scss` in the |
||||||
|
// Active Admin source. |
||||||
|
// |
||||||
|
// For example, to change the sidebar width: |
||||||
|
// $sidebar-width: 242px; |
||||||
|
|
||||||
|
// Active Admin's got SASS! |
||||||
|
@import "~@activeadmin/activeadmin/src/scss/mixins"; |
||||||
|
@import "~@activeadmin/activeadmin/src/scss/base"; |
||||||
|
|
||||||
|
// Overriding any non-variable Sass must be done after the fact. |
||||||
|
// For example, to change the default status-tag color: |
||||||
|
// |
||||||
|
// .status_tag { background: #6090DB; } |
@ -0,0 +1,15 @@ |
|||||||
|
class IncomeRange |
||||||
|
ALLOWED = { |
||||||
|
"Full-time - 30 hours or more": OpenStruct.new(soft_min: 143, soft_max: 730, hard_min: 90, hard_max: 1230), |
||||||
|
"Part-time - Less than 30 hours": OpenStruct.new(soft_min: 67, soft_max: 620, hard_min: 50, hard_max: 950), |
||||||
|
"In government training into work, such as New Deal": OpenStruct.new(soft_min: 80, soft_max: 480, hard_min: 40, hard_max: 990), |
||||||
|
"Jobseeker": OpenStruct.new(soft_min: 50, soft_max: 370, hard_min: 10, hard_max: 450), |
||||||
|
"Retired": OpenStruct.new(soft_min: 50, soft_max: 380, hard_min: 10, hard_max: 690), |
||||||
|
"Not seeking work": OpenStruct.new(soft_min: 53, soft_max: 540, hard_min: 10, hard_max: 890), |
||||||
|
"Full-time student": OpenStruct.new(soft_min: 47, soft_max: 460, hard_min: 10, hard_max: 1300), |
||||||
|
"Unable to work because of long term sick or disability": OpenStruct.new(soft_min: 54, soft_max: 460, hard_min: 10, hard_max: 820), |
||||||
|
"Child under 16": OpenStruct.new(soft_min: 50, soft_max: 450, hard_min: 10, hard_max: 750), |
||||||
|
"Other": OpenStruct.new(soft_min: 50, soft_max: 580, hard_min: 10, hard_max: 1040), |
||||||
|
"Prefer not to say": OpenStruct.new(soft_min: 47, soft_max: 730, hard_min: 10, hard_max: 1300), |
||||||
|
}.freeze |
||||||
|
end |
@ -0,0 +1,37 @@ |
|||||||
|
module FinancialValidations |
||||||
|
# Validations methods need to be called 'validate_<page_name>' to run on model save |
||||||
|
# or 'validate_' to run on submit as well |
||||||
|
def validate_outstanding_rent_amount(record) |
||||||
|
if record.outstanding_rent_or_charges == "Yes" && record.outstanding_amount.blank? |
||||||
|
record.errors.add :outstanding_amount, "You must answer the oustanding amout question if you have outstanding rent or charges." |
||||||
|
end |
||||||
|
if record.outstanding_rent_or_charges == "No" && record.outstanding_amount.present? |
||||||
|
record.errors.add :outstanding_amount, "You must not answer the oustanding amout question if you don't have outstanding rent or charges." |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
EMPLOYED_STATUSES = ["Full-time - 30 hours or more", "Part-time - Less than 30 hours"].freeze |
||||||
|
def validate_net_income_uc_proportion(record) |
||||||
|
(1..8).any? do |n| |
||||||
|
economic_status = record["person_#{n}_economic_status"] |
||||||
|
is_employed = EMPLOYED_STATUSES.include?(economic_status) |
||||||
|
relationship = record["person_#{n}_relationship"] |
||||||
|
is_partner_or_main = relationship == "Partner" || (relationship.nil? && economic_status.present?) |
||||||
|
if is_employed && is_partner_or_main && record.net_income_uc_proportion == "All" |
||||||
|
record.errors.add :net_income_uc_proportion, "income is from Universal Credit, state pensions or benefits cannot be All if the tenant or the partner works part or full time" |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def validate_net_income(record) |
||||||
|
return unless record.person_1_economic_status && record.weekly_net_income |
||||||
|
|
||||||
|
if record.weekly_net_income > record.applicable_income_range.hard_max |
||||||
|
record.errors.add :net_income, "Net income cannot be greater than #{record.applicable_income_range.hard_max} given the tenant's working situation" |
||||||
|
end |
||||||
|
|
||||||
|
if record.weekly_net_income < record.applicable_income_range.hard_min |
||||||
|
record.errors.add :net_income, "Net income cannot be less than #{record.applicable_income_range.hard_min} given the tenant's working situation" |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,167 @@ |
|||||||
|
module HouseholdValidations |
||||||
|
# Validations methods need to be called 'validate_<page_name>' to run on model save |
||||||
|
# or 'validate_' to run on submit as well |
||||||
|
def validate_reasonable_preference(record) |
||||||
|
if record.homelessness == "No" && record.reasonable_preference == "Yes" |
||||||
|
record.errors.add :reasonable_preference, "Can not be Yes if Not Homeless immediately prior to this letting has been selected" |
||||||
|
elsif record.reasonable_preference == "Yes" |
||||||
|
if !record.reasonable_preference_reason_homeless && !record.reasonable_preference_reason_unsatisfactory_housing && !record.reasonable_preference_reason_medical_grounds && !record.reasonable_preference_reason_avoid_hardship && !record.reasonable_preference_reason_do_not_know |
||||||
|
record.errors.add :reasonable_preference_reason, "If reasonable preference is Yes, a reason must be given" |
||||||
|
end |
||||||
|
elsif record.reasonable_preference == "No" |
||||||
|
if record.reasonable_preference_reason_homeless || record.reasonable_preference_reason_unsatisfactory_housing || record.reasonable_preference_reason_medical_grounds || record.reasonable_preference_reason_avoid_hardship || record.reasonable_preference_reason_do_not_know |
||||||
|
record.errors.add :reasonable_preference_reason, "If reasonable preference is No, no reasons should be given" |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def validate_other_reason_for_leaving_last_settled_home(record) |
||||||
|
validate_other_field(record, "reason_for_leaving_last_settled_home", "other_reason_for_leaving_last_settled_home") |
||||||
|
end |
||||||
|
|
||||||
|
def validate_reason_for_leaving_last_settled_home(record) |
||||||
|
if record.reason_for_leaving_last_settled_home == "Do not know" && record.benefit_cap_spare_room_subsidy != "Do not know" |
||||||
|
record.errors.add :benefit_cap_spare_room_subsidy, "must be do not know if tenant’s main reason for leaving is do not know" |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def validate_armed_forces_injured(record) |
||||||
|
if (record.armed_forces == "Yes - a regular" || record.armed_forces == "Yes - a reserve") && record.armed_forces_injured.blank? |
||||||
|
record.errors.add :armed_forces_injured, "You must answer the armed forces injury question if the tenant has served in the armed forces" |
||||||
|
end |
||||||
|
|
||||||
|
if (record.armed_forces == "No" || record.armed_forces == "Prefer not to say") && record.armed_forces_injured.present? |
||||||
|
record.errors.add :armed_forces_injured, "You must not answer the armed forces injury question if the tenant has not served in the armed forces or prefer not to say was chosen" |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def validate_armed_forces_active_response(record) |
||||||
|
if record.armed_forces == "Yes - a regular" && record.armed_forces_active.blank? |
||||||
|
record.errors.add :armed_forces_active, "You must answer the armed forces active question if the tenant has served as a regular in the armed forces" |
||||||
|
end |
||||||
|
|
||||||
|
if record.armed_forces != "Yes - a regular" && record.armed_forces_active.present? |
||||||
|
record.errors.add :armed_forces_active, "You must not answer the armed forces active question if the tenant has not served as a regular in the armed forces" |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def validate_household_pregnancy(record) |
||||||
|
if (record.pregnancy == "Yes" || record.pregnancy == "Prefer not to say") && !women_of_child_bearing_age_in_household(record) |
||||||
|
record.errors.add :pregnancy, "You must answer no as there are no female tenants aged 16-50 in the property" |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def validate_household_number_of_other_members(record) |
||||||
|
(2..8).each do |n| |
||||||
|
validate_person_age(record, n) |
||||||
|
validate_person_age_matches_economic_status(record, n) |
||||||
|
validate_person_age_matches_relationship(record, n) |
||||||
|
validate_person_age_and_gender_match_economic_status(record, n) |
||||||
|
validate_person_age_and_relationship_matches_economic_status(record, n) |
||||||
|
end |
||||||
|
validate_partner_count(record) |
||||||
|
end |
||||||
|
|
||||||
|
def validate_person_1_age(record) |
||||||
|
return unless record.person_1_age |
||||||
|
|
||||||
|
if !record.person_1_age.is_a?(Integer) || record.person_1_age < 16 || record.person_1_age > 120 |
||||||
|
record.errors.add "person_1_age", "Tenant age must be an integer between 16 and 120" |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def validate_person_1_economic(record) |
||||||
|
validate_person_age_matches_economic_status(record, 1) |
||||||
|
end |
||||||
|
|
||||||
|
def validate_shared_housing_rooms(record) |
||||||
|
unless record.property_unit_type.nil? |
||||||
|
if record.property_unit_type == "Bed-sit" && record.property_number_of_bedrooms != 1 |
||||||
|
record.errors.add :property_unit_type, "A bedsit can only have one bedroom" |
||||||
|
end |
||||||
|
|
||||||
|
if !record.household_number_of_other_members.nil? && record.household_number_of_other_members.positive? && (record.property_unit_type.include?("Shared") && !record.property_number_of_bedrooms.to_i.between?(1, 7)) |
||||||
|
record.errors.add :property_unit_type, "A shared house must have 1 to 7 bedrooms" |
||||||
|
end |
||||||
|
|
||||||
|
if record.property_unit_type.include?("Shared") && !record.property_number_of_bedrooms.to_i.between?(1, 3) |
||||||
|
record.errors.add :property_unit_type, "A shared house with less than two tenants must have 1 to 3 bedrooms" |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def women_of_child_bearing_age_in_household(record) |
||||||
|
(1..8).any? do |n| |
||||||
|
next if record["person_#{n}_gender"].nil? || record["person_#{n}_age"].nil? |
||||||
|
|
||||||
|
record["person_#{n}_gender"] == "Female" && record["person_#{n}_age"] >= 16 && record["person_#{n}_age"] <= 50 |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def validate_person_age(record, person_num) |
||||||
|
age = record.public_send("person_#{person_num}_age") |
||||||
|
return unless age |
||||||
|
|
||||||
|
if !age.is_a?(Integer) || age < 1 || age > 120 |
||||||
|
record.errors.add "person_#{person_num}_age".to_sym, "Tenant age must be an integer between 0 and 120" |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def validate_person_age_matches_economic_status(record, person_num) |
||||||
|
age = record.public_send("person_#{person_num}_age") |
||||||
|
economic_status = record.public_send("person_#{person_num}_economic_status") |
||||||
|
return unless age && economic_status |
||||||
|
|
||||||
|
if age > 70 && economic_status != "Retired" |
||||||
|
record.errors.add "person_#{person_num}_economic_status", "Tenant #{person_num} must be retired if over 70" |
||||||
|
end |
||||||
|
if age < 16 && economic_status != "Child under 16" |
||||||
|
record.errors.add "person_#{person_num}_economic_status", "Tenant #{person_num} economic status must be Child under 16 if their age is under 16" |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def validate_person_age_matches_relationship(record, person_num) |
||||||
|
age = record.public_send("person_#{person_num}_age") |
||||||
|
relationship = record.public_send("person_#{person_num}_relationship") |
||||||
|
return unless age && relationship |
||||||
|
|
||||||
|
if age < 16 && relationship != "Child - includes young adult and grown-up" |
||||||
|
record.errors.add "person_#{person_num}_relationship", "Tenant #{person_num}'s relationship to tenant 1 must be Child if their age is under 16" |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def validate_person_age_and_relationship_matches_economic_status(record, person_num) |
||||||
|
age = record.public_send("person_#{person_num}_age") |
||||||
|
economic_status = record.public_send("person_#{person_num}_economic_status") |
||||||
|
relationship = record.public_send("person_#{person_num}_relationship") |
||||||
|
return unless age && economic_status && relationship |
||||||
|
|
||||||
|
if age >= 16 && age <= 19 && relationship == "Child - includes young adult and grown-up" && (economic_status != "Full-time student" || economic_status != "Prefer not to say") |
||||||
|
record.errors.add "person_#{person_num}_economic_status", "If age is between 16 and 19 - tenant #{person_num} must be a full time student or prefer not to say." |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def validate_person_age_and_gender_match_economic_status(record, person_num) |
||||||
|
age = record.public_send("person_#{person_num}_age") |
||||||
|
gender = record.public_send("person_#{person_num}_gender") |
||||||
|
economic_status = record.public_send("person_#{person_num}_economic_status") |
||||||
|
return unless age && economic_status && gender |
||||||
|
|
||||||
|
if gender == "Male" && economic_status == "Retired" && age < 65 |
||||||
|
record.errors.add "person_#{person_num}_age", "Male tenant who is retired must be 65 or over" |
||||||
|
end |
||||||
|
if gender == "Female" && economic_status == "Retired" && age < 60 |
||||||
|
record.errors.add "person_#{person_num}_age", "Female tenant who is retired must be 60 or over" |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def validate_partner_count(record) |
||||||
|
# TODO: probably need to keep track of which specific field is wrong so we can highlight it in the UI |
||||||
|
partner_count = (2..8).count { |n| record.public_send("person_#{n}_relationship") == "Partner" } |
||||||
|
if partner_count > 1 |
||||||
|
record.errors.add :base, "Number of partners cannot be greater than 1" |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,9 @@ |
|||||||
|
module PropertyValidations |
||||||
|
# Validations methods need to be called 'validate_<page_name>' to run on model save |
||||||
|
# or 'validate_' to run on submit as well |
||||||
|
def validate_property_number_of_times_relet(record) |
||||||
|
if record.property_number_of_times_relet && !/^[1-9]$|^0[1-9]$|^1[0-9]$|^20$/.match?(record.property_number_of_times_relet.to_s) |
||||||
|
record.errors.add :property_number_of_times_relet, "Property number of times relet must be between 0 and 20" |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,45 @@ |
|||||||
|
module SoftValidations |
||||||
|
def has_no_unresolved_soft_errors? |
||||||
|
soft_errors.empty? || soft_errors_overridden? |
||||||
|
end |
||||||
|
|
||||||
|
def soft_errors |
||||||
|
{}.merge(net_income_validations) |
||||||
|
end |
||||||
|
|
||||||
|
def soft_errors_overridden? |
||||||
|
public_send(soft_errors.keys.first) if soft_errors.present? |
||||||
|
end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def net_income_validations |
||||||
|
net_income_errors = {} |
||||||
|
if net_income_in_soft_min_range? |
||||||
|
net_income_errors["override_net_income_validation"] = OpenStruct.new( |
||||||
|
message: "Net income is lower than expected based on the main tenant's working situation. Are you sure this is correct?", |
||||||
|
hint_text: "This is based on the tenant's work situation: #{person_1_economic_status}", |
||||||
|
) |
||||||
|
elsif net_income_in_soft_max_range? |
||||||
|
net_income_errors["override_net_income_validation"] = OpenStruct.new( |
||||||
|
message: "Net income is higher than expected based on the main tenant's working situation. Are you sure this is correct?", |
||||||
|
hint_text: "This is based on the tenant's work situation: #{person_1_economic_status}", |
||||||
|
) |
||||||
|
else |
||||||
|
update_column(:override_net_income_validation, nil) |
||||||
|
end |
||||||
|
net_income_errors |
||||||
|
end |
||||||
|
|
||||||
|
def net_income_in_soft_max_range? |
||||||
|
return unless weekly_net_income && person_1_economic_status |
||||||
|
|
||||||
|
weekly_net_income.between?(applicable_income_range.soft_max, applicable_income_range.hard_max) |
||||||
|
end |
||||||
|
|
||||||
|
def net_income_in_soft_min_range? |
||||||
|
return unless weekly_net_income && person_1_economic_status |
||||||
|
|
||||||
|
weekly_net_income.between?(applicable_income_range.soft_min, applicable_income_range.hard_min) |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,21 @@ |
|||||||
|
module TenancyValidations |
||||||
|
# Validations methods need to be called 'validate_<page_name>' to run on model save |
||||||
|
# or 'validate_' to run on submit as well |
||||||
|
def validate_fixed_term_tenancy(record) |
||||||
|
is_present = record.fixed_term_tenancy.present? |
||||||
|
is_in_range = record.fixed_term_tenancy.to_i.between?(2, 99) |
||||||
|
is_secure = record.tenancy_type == "Fixed term – Secure" |
||||||
|
is_ast = record.tenancy_type == "Fixed term – Assured Shorthold Tenancy (AST)" |
||||||
|
conditions = [ |
||||||
|
{ condition: !(is_secure || is_ast) && is_present, error: "You must only answer the fixed term tenancy length question if the tenancy type is fixed term" }, |
||||||
|
{ condition: is_ast && !is_in_range, error: "Fixed term – Assured Shorthold Tenancy (AST) should be between 2 and 99 years" }, |
||||||
|
{ condition: is_secure && (!is_in_range && is_present), error: "Fixed term – Secure should be between 2 and 99 years or not specified" }, |
||||||
|
] |
||||||
|
|
||||||
|
conditions.each { |condition| condition[:condition] ? (record.errors.add :fixed_term_tenancy, condition[:error]) : nil } |
||||||
|
end |
||||||
|
|
||||||
|
def validate_other_tenancy_type(record) |
||||||
|
validate_other_field(record, "tenancy_type", "other_tenancy_type") |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,11 @@ |
|||||||
|
<div class="govuk-form-group govuk-form-group--error"> |
||||||
|
<%= f.govuk_check_boxes_fieldset @case_log.soft_errors.keys.first, |
||||||
|
legend: { text: @case_log.soft_errors.values.first.message, size: "l" }, |
||||||
|
hint: { text: @case_log.soft_errors.values.first.hint_text } do %> |
||||||
|
|
||||||
|
<%= f.govuk_check_box @case_log.soft_errors.keys.first, @case_log.soft_errors.keys.first, |
||||||
|
label: { text: "Yes" }, |
||||||
|
checked: f.object.send(@case_log.soft_errors.keys.first) |
||||||
|
%> |
||||||
|
<% end %> |
||||||
|
</div> |
@ -0,0 +1,335 @@ |
|||||||
|
ActiveAdmin.setup do |config| |
||||||
|
# == Site Title |
||||||
|
# |
||||||
|
# Set the title that is displayed on the main layout |
||||||
|
# for each of the active admin pages. |
||||||
|
# |
||||||
|
config.site_title = "DLUHC CORE" |
||||||
|
|
||||||
|
# Set the link url for the title. For example, to take |
||||||
|
# users to your main site. Defaults to no link. |
||||||
|
# |
||||||
|
# config.site_title_link = "/" |
||||||
|
|
||||||
|
# Set an optional image to be displayed for the header |
||||||
|
# instead of a string (overrides :site_title) |
||||||
|
# |
||||||
|
# Note: Aim for an image that's 21px high so it fits in the header. |
||||||
|
# |
||||||
|
# config.site_title_image = "logo.png" |
||||||
|
|
||||||
|
# == Default Namespace |
||||||
|
# |
||||||
|
# Set the default namespace each administration resource |
||||||
|
# will be added to. |
||||||
|
# |
||||||
|
# eg: |
||||||
|
# config.default_namespace = :hello_world |
||||||
|
# |
||||||
|
# This will create resources in the HelloWorld module and |
||||||
|
# will namespace routes to /hello_world/* |
||||||
|
# |
||||||
|
# To set no namespace by default, use: |
||||||
|
# config.default_namespace = false |
||||||
|
# |
||||||
|
# Default: |
||||||
|
# config.default_namespace = :admin |
||||||
|
# |
||||||
|
# You can customize the settings for each namespace by using |
||||||
|
# a namespace block. For example, to change the site title |
||||||
|
# within a namespace: |
||||||
|
# |
||||||
|
# config.namespace :admin do |admin| |
||||||
|
# admin.site_title = "Custom Admin Title" |
||||||
|
# end |
||||||
|
# |
||||||
|
# This will ONLY change the title for the admin section. Other |
||||||
|
# namespaces will continue to use the main "site_title" configuration. |
||||||
|
|
||||||
|
# == User Authentication |
||||||
|
# |
||||||
|
# Active Admin will automatically call an authentication |
||||||
|
# method in a before filter of all controller actions to |
||||||
|
# ensure that there is a currently logged in admin user. |
||||||
|
# |
||||||
|
# This setting changes the method which Active Admin calls |
||||||
|
# within the application controller. |
||||||
|
# config.authentication_method = :authenticate_admin_user! |
||||||
|
|
||||||
|
# == User Authorization |
||||||
|
# |
||||||
|
# Active Admin will automatically call an authorization |
||||||
|
# method in a before filter of all controller actions to |
||||||
|
# ensure that there is a user with proper rights. You can use |
||||||
|
# CanCanAdapter or make your own. Please refer to documentation. |
||||||
|
# config.authorization_adapter = ActiveAdmin::CanCanAdapter |
||||||
|
|
||||||
|
# In case you prefer Pundit over other solutions you can here pass |
||||||
|
# the name of default policy class. This policy will be used in every |
||||||
|
# case when Pundit is unable to find suitable policy. |
||||||
|
# config.pundit_default_policy = "MyDefaultPunditPolicy" |
||||||
|
|
||||||
|
# If you wish to maintain a separate set of Pundit policies for admin |
||||||
|
# resources, you may set a namespace here that Pundit will search |
||||||
|
# within when looking for a resource's policy. |
||||||
|
# config.pundit_policy_namespace = :admin |
||||||
|
|
||||||
|
# You can customize your CanCan Ability class name here. |
||||||
|
# config.cancan_ability_class = "Ability" |
||||||
|
|
||||||
|
# You can specify a method to be called on unauthorized access. |
||||||
|
# This is necessary in order to prevent a redirect loop which happens |
||||||
|
# because, by default, user gets redirected to Dashboard. If user |
||||||
|
# doesn't have access to Dashboard, he'll end up in a redirect loop. |
||||||
|
# Method provided here should be defined in application_controller.rb. |
||||||
|
# config.on_unauthorized_access = :access_denied |
||||||
|
|
||||||
|
# == Current User |
||||||
|
# |
||||||
|
# Active Admin will associate actions with the current |
||||||
|
# user performing them. |
||||||
|
# |
||||||
|
# This setting changes the method which Active Admin calls |
||||||
|
# (within the application controller) to return the currently logged in user. |
||||||
|
# config.current_user_method = :current_admin_user |
||||||
|
|
||||||
|
# == Logging Out |
||||||
|
# |
||||||
|
# Active Admin displays a logout link on each screen. These |
||||||
|
# settings configure the location and method used for the link. |
||||||
|
# |
||||||
|
# This setting changes the path where the link points to. If it's |
||||||
|
# a string, the strings is used as the path. If it's a Symbol, we |
||||||
|
# will call the method to return the path. |
||||||
|
# |
||||||
|
# Default: |
||||||
|
config.logout_link_path = :destroy_admin_user_session_path |
||||||
|
|
||||||
|
# This setting changes the http method used when rendering the |
||||||
|
# link. For example :get, :delete, :put, etc.. |
||||||
|
# |
||||||
|
# Default: |
||||||
|
# config.logout_link_method = :get |
||||||
|
|
||||||
|
# == Root |
||||||
|
# |
||||||
|
# Set the action to call for the root path. You can set different |
||||||
|
# roots for each namespace. |
||||||
|
# |
||||||
|
# Default: |
||||||
|
# config.root_to = 'dashboard#index' |
||||||
|
|
||||||
|
# == Admin Comments |
||||||
|
# |
||||||
|
# This allows your users to comment on any resource registered with Active Admin. |
||||||
|
# |
||||||
|
# You can completely disable comments: |
||||||
|
config.comments = false |
||||||
|
# |
||||||
|
# You can change the name under which comments are registered: |
||||||
|
# config.comments_registration_name = 'AdminComment' |
||||||
|
# |
||||||
|
# You can change the order for the comments and you can change the column |
||||||
|
# to be used for ordering: |
||||||
|
# config.comments_order = 'created_at ASC' |
||||||
|
# |
||||||
|
# You can disable the menu item for the comments index page: |
||||||
|
# config.comments_menu = false |
||||||
|
# |
||||||
|
# You can customize the comment menu: |
||||||
|
# config.comments_menu = { parent: 'Admin', priority: 1 } |
||||||
|
|
||||||
|
# == Batch Actions |
||||||
|
# |
||||||
|
# Enable and disable Batch Actions |
||||||
|
# |
||||||
|
config.batch_actions = true |
||||||
|
|
||||||
|
# == Controller Filters |
||||||
|
# |
||||||
|
# You can add before, after and around filters to all of your |
||||||
|
# Active Admin resources and pages from here. |
||||||
|
# |
||||||
|
# config.before_action :do_something_awesome |
||||||
|
|
||||||
|
# == Attribute Filters |
||||||
|
# |
||||||
|
# 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] |
||||||
|
|
||||||
|
# == Localize Date/Time Format |
||||||
|
# |
||||||
|
# Set the localize format to display dates and times. |
||||||
|
# To understand how to localize your app with I18n, read more at |
||||||
|
# https://guides.rubyonrails.org/i18n.html |
||||||
|
# |
||||||
|
# You can run `bin/rails runner 'puts I18n.t("date.formats")'` to see the |
||||||
|
# available formats in your application. |
||||||
|
# |
||||||
|
config.localize_format = :long |
||||||
|
|
||||||
|
# == Setting a Favicon |
||||||
|
# |
||||||
|
# config.favicon = 'favicon.ico' |
||||||
|
|
||||||
|
# == Meta Tags |
||||||
|
# |
||||||
|
# Add additional meta tags to the head element of active admin pages. |
||||||
|
# |
||||||
|
# Add tags to all pages logged in users see: |
||||||
|
# config.meta_tags = { author: 'My Company' } |
||||||
|
|
||||||
|
# By default, sign up/sign in/recover password pages are excluded |
||||||
|
# from showing up in search engine results by adding a robots meta |
||||||
|
# tag. You can reset the hash of meta tags included in logged out |
||||||
|
# pages: |
||||||
|
# config.meta_tags_for_logged_out_pages = {} |
||||||
|
|
||||||
|
# == Removing Breadcrumbs |
||||||
|
# |
||||||
|
# Breadcrumbs are enabled by default. You can customize them for individual |
||||||
|
# resources or you can disable them globally from here. |
||||||
|
# |
||||||
|
# config.breadcrumb = false |
||||||
|
|
||||||
|
# == Create Another Checkbox |
||||||
|
# |
||||||
|
# Create another checkbox is disabled by default. You can customize it for individual |
||||||
|
# resources or you can enable them globally from here. |
||||||
|
# |
||||||
|
# config.create_another = true |
||||||
|
|
||||||
|
# == Register Stylesheets & Javascripts |
||||||
|
# |
||||||
|
# We recommend using the built in Active Admin layout and loading |
||||||
|
# up your own stylesheets / javascripts to customize the look |
||||||
|
# and feel. |
||||||
|
# |
||||||
|
# To load a stylesheet: |
||||||
|
# config.register_stylesheet 'my_stylesheet.css' |
||||||
|
# |
||||||
|
# You can provide an options hash for more control, which is passed along to stylesheet_link_tag(): |
||||||
|
# config.register_stylesheet 'my_print_stylesheet.css', media: :print |
||||||
|
# |
||||||
|
# To load a javascript file: |
||||||
|
# config.register_javascript 'my_javascript.js' |
||||||
|
|
||||||
|
# == CSV options |
||||||
|
# |
||||||
|
# Set the CSV builder separator |
||||||
|
# config.csv_options = { col_sep: ';' } |
||||||
|
# |
||||||
|
# Force the use of quotes |
||||||
|
# config.csv_options = { force_quotes: true } |
||||||
|
|
||||||
|
# == Menu System |
||||||
|
# |
||||||
|
# You can add a navigation menu to be used in your application, or configure a provided menu |
||||||
|
# |
||||||
|
# To change the default utility navigation to show a link to your website & a logout btn |
||||||
|
# |
||||||
|
# config.namespace :admin do |admin| |
||||||
|
# admin.build_menu :utility_navigation do |menu| |
||||||
|
# menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank } |
||||||
|
# admin.add_logout_button_to_menu menu |
||||||
|
# end |
||||||
|
# end |
||||||
|
# |
||||||
|
# If you wanted to add a static menu item to the default menu provided: |
||||||
|
# |
||||||
|
# config.namespace :admin do |admin| |
||||||
|
# admin.build_menu :default do |menu| |
||||||
|
# menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank } |
||||||
|
# end |
||||||
|
# end |
||||||
|
|
||||||
|
# == Download Links |
||||||
|
# |
||||||
|
# You can disable download links on resource listing pages, |
||||||
|
# or customize the formats shown per namespace/globally |
||||||
|
# |
||||||
|
# To disable/customize for the :admin namespace: |
||||||
|
# |
||||||
|
# config.namespace :admin do |admin| |
||||||
|
# |
||||||
|
# # Disable the links entirely |
||||||
|
# admin.download_links = false |
||||||
|
# |
||||||
|
# # Only show XML & PDF options |
||||||
|
# admin.download_links = [:xml, :pdf] |
||||||
|
# |
||||||
|
# # Enable/disable the links based on block |
||||||
|
# # (for example, with cancan) |
||||||
|
# admin.download_links = proc { can?(:view_download_links) } |
||||||
|
# |
||||||
|
# end |
||||||
|
|
||||||
|
# == Pagination |
||||||
|
# |
||||||
|
# Pagination is enabled by default for all resources. |
||||||
|
# You can control the default per page count for all resources here. |
||||||
|
# |
||||||
|
# config.default_per_page = 30 |
||||||
|
# |
||||||
|
# You can control the max per page count too. |
||||||
|
# |
||||||
|
# config.max_per_page = 10_000 |
||||||
|
|
||||||
|
# == Filters |
||||||
|
# |
||||||
|
# By default the index screen includes a "Filters" sidebar on the right |
||||||
|
# hand side with a filter for each attribute of the registered model. |
||||||
|
# You can enable or disable them for all resources here. |
||||||
|
# |
||||||
|
# config.filters = true |
||||||
|
# |
||||||
|
# By default the filters include associations in a select, which means |
||||||
|
# that every record will be loaded for each association (up |
||||||
|
# to the value of config.maximum_association_filter_arity). |
||||||
|
# You can enabled or disable the inclusion |
||||||
|
# of those filters by default here. |
||||||
|
# |
||||||
|
# config.include_default_association_filters = true |
||||||
|
|
||||||
|
# config.maximum_association_filter_arity = 256 # default value of :unlimited will change to 256 in a future version |
||||||
|
# config.filter_columns_for_large_association = [ |
||||||
|
# :display_name, |
||||||
|
# :full_name, |
||||||
|
# :name, |
||||||
|
# :username, |
||||||
|
# :login, |
||||||
|
# :title, |
||||||
|
# :email, |
||||||
|
# ] |
||||||
|
# config.filter_method_for_large_association = '_starts_with' |
||||||
|
|
||||||
|
# == Head |
||||||
|
# |
||||||
|
# You can add your own content to the site head like analytics. Make sure |
||||||
|
# you only pass content you trust. |
||||||
|
# |
||||||
|
# config.head = ''.html_safe |
||||||
|
|
||||||
|
# == Footer |
||||||
|
# |
||||||
|
# By default, the footer shows the current Active Admin version. You can |
||||||
|
# override the content of the footer here. |
||||||
|
# |
||||||
|
# config.footer = 'my custom footer text' |
||||||
|
|
||||||
|
# == Sorting |
||||||
|
# |
||||||
|
# By default ActiveAdmin::OrderClause is used for sorting logic |
||||||
|
# You can inherit it with own class and inject it for all resources |
||||||
|
# |
||||||
|
# config.order_clause = MyOrderClause |
||||||
|
|
||||||
|
# == Webpacker |
||||||
|
# |
||||||
|
# By default, Active Admin uses Sprocket's asset pipeline. |
||||||
|
# You can switch to using Webpacker here. |
||||||
|
# |
||||||
|
config.use_webpacker = true |
||||||
|
end |
@ -1,3 +1,5 @@ |
|||||||
const { environment } = require('@rails/webpacker') |
const { environment } = require('@rails/webpacker') |
||||||
|
const jquery = require('./plugins/jquery') |
||||||
|
|
||||||
|
environment.plugins.prepend('jquery', jquery) |
||||||
module.exports = environment |
module.exports = environment |
||||||
|
@ -0,0 +1,7 @@ |
|||||||
|
const webpack = require('webpack') |
||||||
|
|
||||||
|
module.exports = new webpack.ProvidePlugin({ |
||||||
|
"$":"jquery", |
||||||
|
"jQuery":"jquery", |
||||||
|
"window.jQuery":"jquery" |
||||||
|
}); |
@ -0,0 +1,9 @@ |
|||||||
|
class ChangeNetIncomeType < ActiveRecord::Migration[6.1] |
||||||
|
def up |
||||||
|
change_column :case_logs, :net_income, "integer USING CAST(property_number_of_times_relet AS integer)" |
||||||
|
end |
||||||
|
|
||||||
|
def down |
||||||
|
change_column :case_logs, :net_income, :string |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,5 @@ |
|||||||
|
class AddNetIncomeOverride < ActiveRecord::Migration[6.1] |
||||||
|
def change |
||||||
|
add_column :case_logs, :override_net_income_validation, :boolean |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,7 @@ |
|||||||
|
class AddNetIncomeKnownField < ActiveRecord::Migration[6.1] |
||||||
|
def change |
||||||
|
change_table :case_logs, bulk: true do |t| |
||||||
|
t.column :net_income_known, :string |
||||||
|
end |
||||||
|
end |
||||||
|
end |
Loading…
Reference in new issue