Browse Source

Merge branch 'main' into CLDC-2639-back-to-logs-button

pull/2721/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
98d0ec8933
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 17
      app/controllers/users_controller.rb
  2. 4
      app/models/form/sales/pages/household_wheelchair_check.rb
  3. 3
      app/models/form/sales/questions/armed_forces.rb
  4. 2
      app/models/form/sales/questions/armed_forces_spouse.rb
  5. 2
      app/models/form/sales/questions/buyer_still_serving.rb
  6. 3
      app/models/form/sales/questions/household_disability.rb
  7. 2
      app/models/form/sales/questions/household_wheelchair.rb
  8. 3
      app/models/form/sales/questions/household_wheelchair_check.rb
  9. 6
      app/models/user.rb
  10. 2
      config/locales/en.yml
  11. 34
      config/locales/forms/2023/sales/household_needs.en.yml
  12. 6
      config/locales/forms/2023/sales/soft_validations.en.yml
  13. 34
      config/locales/forms/2024/sales/household_needs.en.yml
  14. 6
      config/locales/forms/2024/sales/soft_validations.en.yml
  15. 3
      spec/models/form/sales/pages/household_wheelchair_check_spec.rb
  16. 3
      spec/models/form/sales/subsections/household_needs_spec.rb

17
app/controllers/users_controller.rb

@ -257,13 +257,7 @@ private
def user_params def user_params
if @user == current_user if @user == current_user
if current_user.data_coordinator? current_user_params
params.require(:user).permit(:email, :phone, :phone_extension, :name, :password, :password_confirmation, :role, :is_dpo, :is_key_contact, :initial_confirmation_sent)
elsif current_user.support?
params.require(:user).permit(:email, :phone, :phone_extension, :name, :password, :password_confirmation, :role, :is_dpo, :is_key_contact, :initial_confirmation_sent, :organisation_id)
else
params.require(:user).permit(:email, :phone, :phone_extension, :name, :password, :password_confirmation, :initial_confirmation_sent)
end
elsif current_user.data_coordinator? elsif current_user.data_coordinator?
params.require(:user).permit(:email, :phone, :phone_extension, :name, :role, :is_dpo, :is_key_contact, :active, :initial_confirmation_sent) params.require(:user).permit(:email, :phone, :phone_extension, :name, :role, :is_dpo, :is_key_contact, :active, :initial_confirmation_sent)
elsif current_user.support? elsif current_user.support?
@ -271,6 +265,15 @@ private
end end
end end
def current_user_params
base_params = %i[email phone phone_extension name password password_confirmation initial_confirmation_sent]
return params.require(:user).permit(*(base_params + %i[role is_dpo is_key_contact])) if current_user.data_coordinator?
return params.require(:user).permit(*(base_params + %i[role is_dpo is_key_contact organisation_id])) if current_user.support?
return params.require(:user).permit(*(base_params + [:role])) if Rails.env.staging? && current_user.in_staging_role_update_email_allowlist?
params.require(:user).permit(*base_params)
end
def user_params_without_org def user_params_without_org
user_params.except(:organisation_id) user_params.except(:organisation_id)
end end

4
app/models/form/sales/pages/household_wheelchair_check.rb

@ -6,8 +6,8 @@ class Form::Sales::Pages::HouseholdWheelchairCheck < ::Form::Page
"wheelchair_when_not_disabled?" => true, "wheelchair_when_not_disabled?" => true,
}, },
] ]
@informative_text = {} @copy_key = "sales.soft_validations.wheel_value_check"
@title_text = { "translation" => "soft_validations.wheelchair.title_text" } @title_text = { "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text" }
end end
def questions def questions

3
app/models/form/sales/questions/armed_forces.rb

@ -2,10 +2,7 @@ class Form::Sales::Questions::ArmedForces < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "hhregres" @id = "hhregres"
@check_answer_label = "Have any of the buyers ever served as a regular in the UK armed forces?"
@header = "Have any of the buyers ever served as a regular in the UK armed forces?"
@type = "radio" @type = "radio"
@hint_text = "A regular is somebody who has served in the Royal Navy, the Royal Marines, the Royal Airforce or Army full time and does not include reserve forces"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

2
app/models/form/sales/questions/armed_forces_spouse.rb

@ -2,8 +2,6 @@ class Form::Sales::Questions::ArmedForcesSpouse < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "armedforcesspouse" @id = "armedforcesspouse"
@check_answer_label = "Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?"
@header = "Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?"
@type = "radio" @type = "radio"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]

2
app/models/form/sales/questions/buyer_still_serving.rb

@ -2,8 +2,6 @@ class Form::Sales::Questions::BuyerStillServing < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "hhregresstill" @id = "hhregresstill"
@check_answer_label = "Are they still serving in the UK armed forces?"
@header = "Is the buyer still serving in the UK armed forces?"
@type = "radio" @type = "radio"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]

3
app/models/form/sales/questions/household_disability.rb

@ -2,11 +2,8 @@ class Form::Sales::Questions::HouseholdDisability < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "disabled" @id = "disabled"
@header = "Does anyone in the household consider themselves to have a disability?"
@check_answer_label = "Does anyone in the household have a disability?"
@type = "radio" @type = "radio"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@hint_text = "This includes any long-term health condition that has an impact on the person's day-to-day life"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

2
app/models/form/sales/questions/household_wheelchair.rb

@ -2,10 +2,8 @@ class Form::Sales::Questions::HouseholdWheelchair < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "wheel" @id = "wheel"
@header = "Does anyone in the household use a wheelchair?"
@type = "radio" @type = "radio"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@hint_text = "This can be inside or outside the home"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

3
app/models/form/sales/questions/household_wheelchair_check.rb

@ -2,8 +2,7 @@ class Form::Sales::Questions::HouseholdWheelchairCheck < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "wheel_value_check" @id = "wheel_value_check"
@check_answer_label = "Does anyone in the household use a wheelchair?" @copy_key = "sales.soft_validations.wheel_value_check"
@header = "You told us that someone in the household uses a wheelchair."
@type = "interruption_screen" @type = "interruption_screen"
@answer_options = { @answer_options = {
"0" => { "value" => "Yes" }, "0" => { "value" => "Yes" },

6
app/models/user.rb

@ -212,7 +212,7 @@ class User < ApplicationRecord
end end
def assignable_roles def assignable_roles
if Rails.env.staging? && Rails.application.credentials[:staging_role_update_email_allowlist].include?(email.split("@").last.downcase) if Rails.env.staging? && in_staging_role_update_email_allowlist?
return ROLES return ROLES
end end
@ -222,6 +222,10 @@ class User < ApplicationRecord
ROLES.except(:support) ROLES.except(:support)
end end
def in_staging_role_update_email_allowlist?
Rails.application.credentials[:staging_role_update_email_allowlist].include?(email.split("@").last.downcase)
end
def logs_filters(specific_org: false) def logs_filters(specific_org: false)
if (support? && !specific_org) || organisation.has_managing_agents? || organisation.has_stock_owners? if (support? && !specific_org) || organisation.has_managing_agents? || organisation.has_stock_owners?
%w[years status needstypes assigned_to user owning_organisation managing_organisation bulk_upload_id user_text_search owning_organisation_text_search managing_organisation_text_search] %w[years status needstypes assigned_to user owning_organisation managing_organisation bulk_upload_id user_text_search owning_organisation_text_search managing_organisation_text_search]

2
config/locales/en.yml

@ -754,8 +754,6 @@ Make sure these answers are correct."
grant: grant:
title_text: "You told us that the grant amount is %{grant}." title_text: "You told us that the grant amount is %{grant}."
hint_text: "Loans, grants and subsidies are usually between £9,000 and £16,000." hint_text: "Loans, grants and subsidies are usually between £9,000 and £16,000."
wheelchair:
title_text: "You told us that someone in the household uses a wheelchair."
referral: referral:
title_text: "Are you sure?" title_text: "Are you sure?"
hint_text: "This is a general needs log, and this referral type is for supported housing." hint_text: "This is a general needs log, and this referral type is for supported housing."

34
config/locales/forms/2023/sales/household_needs.en.yml

@ -0,0 +1,34 @@
en:
forms:
2023:
sales:
household_needs:
hhregres:
page_header: ""
check_answer_label: "Have any of the buyers ever served as a regular in the UK armed forces?"
hint_text: "A regular is somebody who has served in the Royal Navy, the Royal Marines, the Royal Airforce or Army full time and does not include reserve forces"
question_text: "Have any of the buyers ever served as a regular in the UK armed forces?"
hhregresstill:
page_header: ""
check_answer_label: "Are they still serving in the UK armed forces?"
hint_text: ""
question_text: "Is the buyer still serving in the UK armed forces?"
armedforcesspouse:
page_header: ""
check_answer_label: "Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?"
hint_text: ""
question_text: "Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?"
disabled:
page_header: ""
check_answer_label: "Does anyone in the household have a disability?"
hint_text: "This includes any long-term health condition that has an impact on the person's day-to-day life"
question_text: "Does anyone in the household consider themselves to have a disability?"
wheel:
page_header: ""
check_answer_label: "Does anyone in the household use a wheelchair?"
hint_text: "This can be inside or outside the home"
question_text: "Does anyone in the household use a wheelchair?"

6
config/locales/forms/2023/sales/soft_validations.en.yml

@ -58,3 +58,9 @@ en:
not_joint_purchase: not_joint_purchase:
title_text: "You told us the buyer’s deposit was %{deposit} and their savings were %{savings}." title_text: "You told us the buyer’s deposit was %{deposit} and their savings were %{savings}."
informative_text: "The deposit amount is higher than we would expect for the amount of savings they have." informative_text: "The deposit amount is higher than we would expect for the amount of savings they have."
wheel_value_check:
page_header: ""
check_answer_label: "Does anyone in the household use a wheelchair?"
hint_text: ""
question_text: "You told us that someone in the household uses a wheelchair."
title_text: "You told us that someone in the household uses a wheelchair."

34
config/locales/forms/2024/sales/household_needs.en.yml

@ -0,0 +1,34 @@
en:
forms:
2024:
sales:
household_needs:
hhregres:
page_header: ""
check_answer_label: "Have any of the buyers ever served as a regular in the UK armed forces?"
hint_text: "A regular is somebody who has served in the Royal Navy, the Royal Marines, the Royal Airforce or Army full time and does not include reserve forces"
question_text: "Have any of the buyers ever served as a regular in the UK armed forces?"
hhregresstill:
page_header: ""
check_answer_label: "Are they still serving in the UK armed forces?"
hint_text: ""
question_text: "Is the buyer still serving in the UK armed forces?"
armedforcesspouse:
page_header: ""
check_answer_label: "Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?"
hint_text: ""
question_text: "Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?"
disabled:
page_header: ""
check_answer_label: "Does anyone in the household have a disability?"
hint_text: "This includes any long-term health condition that has an impact on the person's day-to-day life"
question_text: "Does anyone in the household consider themselves to have a disability?"
wheel:
page_header: ""
check_answer_label: "Does anyone in the household use a wheelchair?"
hint_text: "This can be inside or outside the home"
question_text: "Does anyone in the household use a wheelchair?"

6
config/locales/forms/2024/sales/soft_validations.en.yml

@ -58,3 +58,9 @@ en:
not_joint_purchase: not_joint_purchase:
title_text: "You told us the buyer’s deposit was %{deposit} and their savings were %{savings}." title_text: "You told us the buyer’s deposit was %{deposit} and their savings were %{savings}."
informative_text: "The deposit amount is higher than we would expect for the amount of savings they have." informative_text: "The deposit amount is higher than we would expect for the amount of savings they have."
wheel_value_check:
page_header: ""
check_answer_label: "Does anyone in the household use a wheelchair?"
hint_text: ""
question_text: "You told us that someone in the household uses a wheelchair."
title_text: "You told us that someone in the household uses a wheelchair."

3
spec/models/form/sales/pages/household_wheelchair_check_spec.rb

@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::HouseholdWheelchairCheck, type: :model do
let(:page_id) { "buyer_1_income_mortgage_value_check" } let(:page_id) { "buyer_1_income_mortgage_value_check" }
let(:page_definition) { nil } let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) } let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:subsection) { instance_double(Form::Subsection, form:) }
it "has correct subsection" do it "has correct subsection" do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)

3
spec/models/form/sales/subsections/household_needs_spec.rb

@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Subsections::HouseholdNeeds, type: :model do
let(:subsection_id) { nil } let(:subsection_id) { nil }
let(:subsection_definition) { nil } let(:subsection_definition) { nil }
let(:section) { instance_double(Form::Sales::Sections::Household) } let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:section) { instance_double(Form::Sales::Sections::Household, form:) }
it "has correct section" do it "has correct section" do
expect(household_characteristics.section).to eq(section) expect(household_characteristics.section).to eq(section)

Loading…
Cancel
Save