|
|
@ -25,9 +25,9 @@ class SchemesController < ApplicationController |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def create |
|
|
|
def create |
|
|
|
@scheme = Scheme.new(scheme_params) |
|
|
|
@scheme = Scheme.new(scheme_params.except(:support_services_provider_before_type_cast)) |
|
|
|
|
|
|
|
|
|
|
|
validation_errors scheme_params |
|
|
|
validation_errors scheme_params.except(:support_services_provider_before_type_cast) |
|
|
|
|
|
|
|
|
|
|
|
if @scheme.errors.empty? && @scheme.save |
|
|
|
if @scheme.errors.empty? && @scheme.save |
|
|
|
if scheme_params[:support_services_provider].zero? |
|
|
|
if scheme_params[:support_services_provider].zero? |
|
|
@ -46,9 +46,9 @@ class SchemesController < ApplicationController |
|
|
|
check_answers = params[:scheme][:check_answers] |
|
|
|
check_answers = params[:scheme][:check_answers] |
|
|
|
page = params[:scheme][:page] |
|
|
|
page = params[:scheme][:page] |
|
|
|
|
|
|
|
|
|
|
|
validation_errors scheme_params |
|
|
|
validation_errors scheme_params.except(:support_services_provider_before_type_cast) |
|
|
|
|
|
|
|
|
|
|
|
if @scheme.errors.empty? && @scheme.update(scheme_params) |
|
|
|
if @scheme.errors.empty? && @scheme.update(scheme_params.except(:support_services_provider_before_type_cast)) |
|
|
|
if check_answers |
|
|
|
if check_answers |
|
|
|
if confirm_secondary_page? page |
|
|
|
if confirm_secondary_page? page |
|
|
|
redirect_to scheme_secondary_client_group_path(@scheme, check_answers: "true") |
|
|
|
redirect_to scheme_secondary_client_group_path(@scheme, check_answers: "true") |
|
|
@ -162,18 +162,24 @@ private |
|
|
|
:secondary_client_group, |
|
|
|
:secondary_client_group, |
|
|
|
:support_type, |
|
|
|
:support_type, |
|
|
|
:support_services_provider, |
|
|
|
:support_services_provider, |
|
|
|
|
|
|
|
:support_services_provider_before_type_cast, |
|
|
|
:intended_stay) |
|
|
|
:intended_stay) |
|
|
|
|
|
|
|
|
|
|
|
same_org_providing_support = required_params[:support_services_provider] == "0" |
|
|
|
same_org_providing_support = required_params[:support_services_provider_before_type_cast] == "0" |
|
|
|
|
|
|
|
|
|
|
|
full_params = same_org_providing_support && required_params[:owning_organisation_id].present? ? required_params.merge(managing_organisation_id: required_params[:owning_organisation_id]) : required_params |
|
|
|
full_params = same_org_providing_support && required_params[:owning_organisation_id].present? ? required_params.merge(managing_organisation_id: required_params[:owning_organisation_id]) : required_params |
|
|
|
|
|
|
|
|
|
|
|
full_params[:sensitive] = full_params[:sensitive].to_i if full_params[:sensitive] |
|
|
|
full_params[:sensitive] = full_params[:sensitive].to_i if full_params[:sensitive] |
|
|
|
full_params[:support_services_provider] = full_params[:support_services_provider].to_i if full_params[:support_services_provider] |
|
|
|
|
|
|
|
|
|
|
|
if full_params[:support_services_provider_before_type_cast] |
|
|
|
|
|
|
|
translated_params = full_params.merge(support_services_provider: full_params[:support_services_provider_before_type_cast].to_i) |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
translated_params = full_params |
|
|
|
|
|
|
|
end |
|
|
|
if current_user.data_coordinator? |
|
|
|
if current_user.data_coordinator? |
|
|
|
full_params[:owning_organisation_id] = current_user.organisation_id |
|
|
|
translated_params[:owning_organisation_id] = current_user.organisation_id |
|
|
|
end |
|
|
|
end |
|
|
|
full_params |
|
|
|
translated_params |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def search_term |
|
|
|
def search_term |
|
|
|