|
|
|
@ -61,7 +61,12 @@ class LocationsController < ApplicationController
|
|
|
|
|
error_message = I18n.t("validations.location_admin_district") |
|
|
|
|
@location.errors.add :location_admin_district, error_message |
|
|
|
|
render :edit_local_authority, status: :unprocessable_entity |
|
|
|
|
elsif @location.update(location_params) |
|
|
|
|
else |
|
|
|
|
if page == "edit-local-authority" |
|
|
|
|
la_list = FormHandler.instance.current_lettings_form.get_question("la", nil).answer_options |
|
|
|
|
params[:location][:location_code] = la_list.key(params[:location][:location_admin_district]) |
|
|
|
|
end |
|
|
|
|
if @location.update(location_params) |
|
|
|
|
case page |
|
|
|
|
when "edit" |
|
|
|
|
if @location.location_admin_district.nil? |
|
|
|
@ -84,6 +89,7 @@ class LocationsController < ApplicationController
|
|
|
|
|
render :edit, status: :unprocessable_entity |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
private |
|
|
|
|
|
|
|
|
@ -123,7 +129,7 @@ private
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def location_params |
|
|
|
|
required_params = params.require(:location).permit(:postcode, :name, :units, :type_of_unit, :add_another_location, :startdate, :mobility_type, :location_admin_district).merge(scheme_id: @scheme.id) |
|
|
|
|
required_params = params.require(:location).permit(:postcode, :name, :units, :type_of_unit, :add_another_location, :startdate, :mobility_type, :location_admin_district, :location_code).merge(scheme_id: @scheme.id) |
|
|
|
|
required_params[:postcode] = PostcodeService.clean(required_params[:postcode]) if required_params[:postcode] |
|
|
|
|
required_params |
|
|
|
|
end |
|
|
|
|