From a90ad6f0c535758b32bb8b3767dec4d6d1f57aff Mon Sep 17 00:00:00 2001 From: Kat Date: Wed, 9 Nov 2022 09:28:11 +0000 Subject: [PATCH] Update routes --- app/controllers/locations_controller.rb | 10 +++++----- app/controllers/schemes_controller.rb | 2 +- app/helpers/check_answers_helper.rb | 6 +++--- app/views/locations/edit.html.erb | 2 +- app/views/locations/edit_local_authority.html.erb | 2 +- app/views/locations/edit_name.html.erb | 2 +- app/views/locations/index.html.erb | 2 +- app/views/locations/new.html.erb | 2 +- app/views/schemes/check_answers.html.erb | 2 +- config/routes.rb | 5 ++--- 10 files changed, 17 insertions(+), 18 deletions(-) diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index 532ab915a..1759ac1d6 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -23,9 +23,9 @@ class LocationsController < ApplicationController @location = Location.new(location_params) if @location.save 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(edit_local_authority_scheme_location_path(scheme_id: @scheme.id, id: @location.id, add_another_location: location_params[:add_another_location])) elsif location_params[:add_another_location] == "Yes" - redirect_to new_location_path(@scheme) + redirect_to new_scheme_location_path(@scheme) else check_answers_path = @scheme.confirmed? ? scheme_check_answers_path(@scheme, anchor: "locations") : scheme_check_answers_path(@scheme) redirect_to check_answers_path @@ -71,7 +71,7 @@ class LocationsController < ApplicationController 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])) elsif location_params[:add_another_location] == "Yes" - redirect_to(new_location_path(@location.scheme)) + redirect_to(new_scheme_location_path(@location.scheme)) else redirect_to(scheme_check_answers_path(@scheme, anchor: "locations")) end @@ -79,7 +79,7 @@ class LocationsController < ApplicationController redirect_to(scheme_check_answers_path(@scheme, anchor: "locations")) when "edit-local-authority" if params[:add_another_location] == "Yes" - redirect_to(new_location_path(@location.scheme)) + redirect_to(new_scheme_location_path(@location.scheme)) else redirect_to(scheme_check_answers_path(@scheme, anchor: "locations")) end @@ -107,7 +107,7 @@ private def find_scheme @scheme = if %w[new create index edit_name].include?(action_name) - Scheme.find(params[:id]) + Scheme.find(params[:scheme_id]) else @location&.scheme end diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb index d4168e355..9a259e3a1 100644 --- a/app/controllers/schemes_controller.rb +++ b/app/controllers/schemes_controller.rb @@ -176,7 +176,7 @@ private when "secondary-client-group" scheme_support_path(@scheme) when "support" - new_location_path + new_scheme_location_path(@scheme) when "details" if @scheme.arrangement_type_before_type_cast == "D" scheme_primary_client_group_path(@scheme) diff --git a/app/helpers/check_answers_helper.rb b/app/helpers/check_answers_helper.rb index b334ab073..0be14641c 100644 --- a/app/helpers/check_answers_helper.rb +++ b/app/helpers/check_answers_helper.rb @@ -18,14 +18,14 @@ module CheckAnswersHelper def get_location_change_link_href_postcode(scheme, location) if location.confirmed? - location_edit_name_path(id: scheme.id, location_id: location.id) + edit_name_scheme_location_path(scheme_id: scheme.id, id: location.id) else - location_edit_path(id: scheme.id, location_id: location.id) + edit_scheme_location_path(scheme_id: scheme.id, id: location.id) end end def get_location_change_link_href_location_admin_district(scheme, location) - location_edit_local_authority_path(id: scheme.id, location_id: location.id) + edit_local_authority_scheme_location_path(scheme_id: scheme.id, id: location.id) end def any_questions_have_summary_card_number?(subsection, lettings_log) diff --git a/app/views/locations/edit.html.erb b/app/views/locations/edit.html.erb index 6e14503ed..dca0d04fb 100644 --- a/app/views/locations/edit.html.erb +++ b/app/views/locations/edit.html.erb @@ -7,7 +7,7 @@ ) %> <% end %> -<%= form_for(@location, method: :patch, url: location_path(@location)) do |f| %> +<%= form_for(@location, method: :patch, url: scheme_location_path(scheme_id: @scheme.id, id: @location.id)) do |f| %>
<%= f.govuk_error_summary %> diff --git a/app/views/locations/edit_local_authority.html.erb b/app/views/locations/edit_local_authority.html.erb index 43c351d28..1e5ab9fbb 100644 --- a/app/views/locations/edit_local_authority.html.erb +++ b/app/views/locations/edit_local_authority.html.erb @@ -5,7 +5,7 @@ ) %> <% end %> -<%= form_for(@location, method: :patch, url: location_path(location_id: @location.id, add_another_location: params[:add_another_location])) do |f| %> +<%= form_for(@location, method: :patch, url: scheme_location_path(scheme_id: @scheme.id, id: @location.id, add_another_location: params[:add_another_location])) do |f| %>
<%= f.govuk_error_summary %> diff --git a/app/views/locations/edit_name.html.erb b/app/views/locations/edit_name.html.erb index 087ca0812..ece4df866 100644 --- a/app/views/locations/edit_name.html.erb +++ b/app/views/locations/edit_name.html.erb @@ -7,7 +7,7 @@ ) %> <% end %> -<%= form_for(@location, method: :patch, url: location_path(location_id: @location.id)) do |f| %> +<%= form_for(@location, method: :patch, url: scheme_location_path(scheme_id: @scheme.id, id: @location.id)) do |f| %>
<%= f.govuk_error_summary %> diff --git a/app/views/locations/index.html.erb b/app/views/locations/index.html.erb index 6672fc661..703fd9fa5 100644 --- a/app/views/locations/index.html.erb +++ b/app/views/locations/index.html.erb @@ -62,6 +62,6 @@ <% end %> <% end %> <% end %> -<%= govuk_button_link_to "Add a location", new_location_path(id: @scheme.id), secondary: true %> +<%= govuk_button_link_to "Add a location", new_scheme_location_path(scheme_id: @scheme.id), secondary: true %> <%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "locations" } %> diff --git a/app/views/locations/new.html.erb b/app/views/locations/new.html.erb index 71690f8e6..69f56744b 100644 --- a/app/views/locations/new.html.erb +++ b/app/views/locations/new.html.erb @@ -7,7 +7,7 @@ ) %> <% end %> -<%= form_for(@location, method: :post, url: locations_path) do |f| %> +<%= form_for(@location, method: :post, url: scheme_locations_path) do |f| %>
<%= f.govuk_error_summary %> diff --git a/app/views/schemes/check_answers.html.erb b/app/views/schemes/check_answers.html.erb index 2cb154e1f..a41b202ad 100644 --- a/app/views/schemes/check_answers.html.erb +++ b/app/views/schemes/check_answers.html.erb @@ -78,7 +78,7 @@ <% end %> <% end %> <% end %> - <%= govuk_button_link_to "Add a location", new_location_path(id: @scheme.id), secondary: true %> + <%= govuk_button_link_to "Add a location", new_scheme_location_path(scheme_id: @scheme.id), secondary: true %> <% end %> <% end %> <%= f.hidden_field :page, value: "check-answers" %> diff --git a/config/routes.rb b/config/routes.rb index 9d5083e1f..97bf743bb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -50,10 +50,9 @@ Rails.application.routes.draw do get "edit-name", to: "schemes#edit_name" get "support-services-provider", to: "schemes#support_services_provider" - member do - resources :locations do + resources :locations do + member do get "edit-name", to: "locations#edit_name" - get "edit", to: "locations#edit" get "edit-local-authority", to: "locations#edit_local_authority" end end