|
|
@ -23,9 +23,9 @@ class LocationsController < ApplicationController |
|
|
|
@location = Location.new(location_params) |
|
|
|
@location = Location.new(location_params) |
|
|
|
if @location.save |
|
|
|
if @location.save |
|
|
|
if @location.location_admin_district.nil? |
|
|
|
if @location.location_admin_district.nil? |
|
|
|
redirect_to(location_edit_local_authority_path(id: @scheme.id, location_id: @location.id, add_another_location: location_params[:add_another_location])) |
|
|
|
redirect_to(scheme_location_edit_local_authority_path(scheme_id: @scheme.id, location_id: @location.id, add_another_location: location_params[:add_another_location])) |
|
|
|
elsif location_params[:add_another_location] == "Yes" |
|
|
|
elsif location_params[:add_another_location] == "Yes" |
|
|
|
redirect_to new_location_path(@scheme) |
|
|
|
redirect_to new_scheme_location_path(@scheme) |
|
|
|
else |
|
|
|
else |
|
|
|
check_answers_path = @scheme.confirmed? ? scheme_check_answers_path(@scheme, anchor: "locations") : scheme_check_answers_path(@scheme) |
|
|
|
check_answers_path = @scheme.confirmed? ? scheme_check_answers_path(@scheme, anchor: "locations") : scheme_check_answers_path(@scheme) |
|
|
|
redirect_to check_answers_path |
|
|
|
redirect_to check_answers_path |
|
|
@ -69,9 +69,9 @@ class LocationsController < ApplicationController |
|
|
|
case page |
|
|
|
case page |
|
|
|
when "edit" |
|
|
|
when "edit" |
|
|
|
if @location.location_admin_district.nil? |
|
|
|
if @location.location_admin_district.nil? |
|
|
|
redirect_to(location_edit_local_authority_path(id: @scheme.id, location_id: @location.id, add_another_location: location_params[:add_another_location])) |
|
|
|
redirect_to(scheme_location_edit_local_authority_path(scheme_id: @scheme.id, location_id: @location.id, add_another_location: location_params[:add_another_location])) |
|
|
|
elsif location_params[:add_another_location] == "Yes" |
|
|
|
elsif location_params[:add_another_location] == "Yes" |
|
|
|
redirect_to(new_location_path(@location.scheme)) |
|
|
|
redirect_to(new_scheme_location_path(@location.scheme)) |
|
|
|
else |
|
|
|
else |
|
|
|
redirect_to(scheme_check_answers_path(@scheme, anchor: "locations")) |
|
|
|
redirect_to(scheme_check_answers_path(@scheme, anchor: "locations")) |
|
|
|
end |
|
|
|
end |
|
|
@ -79,7 +79,7 @@ class LocationsController < ApplicationController |
|
|
|
redirect_to(scheme_check_answers_path(@scheme, anchor: "locations")) |
|
|
|
redirect_to(scheme_check_answers_path(@scheme, anchor: "locations")) |
|
|
|
when "edit-local-authority" |
|
|
|
when "edit-local-authority" |
|
|
|
if params[:add_another_location] == "Yes" |
|
|
|
if params[:add_another_location] == "Yes" |
|
|
|
redirect_to(new_location_path(@location.scheme)) |
|
|
|
redirect_to(new_scheme_location_path(@location.scheme)) |
|
|
|
else |
|
|
|
else |
|
|
|
redirect_to(scheme_check_answers_path(@scheme, anchor: "locations")) |
|
|
|
redirect_to(scheme_check_answers_path(@scheme, anchor: "locations")) |
|
|
|
end |
|
|
|
end |
|
|
@ -107,7 +107,7 @@ private |
|
|
|
|
|
|
|
|
|
|
|
def find_scheme |
|
|
|
def find_scheme |
|
|
|
@scheme = if %w[new create index edit_name].include?(action_name) |
|
|
|
@scheme = if %w[new create index edit_name].include?(action_name) |
|
|
|
Scheme.find(params[:id]) |
|
|
|
Scheme.find(params[:scheme_id]) |
|
|
|
else |
|
|
|
else |
|
|
|
@location&.scheme |
|
|
|
@location&.scheme |
|
|
|
end |
|
|
|
end |
|
|
|