diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index a54766bb2..b5efe1e04 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -56,11 +56,11 @@ class LocationsController < ApplicationController if params[:location].present? @location.mobility_type = params[:location][:mobility_type] @location.save! - redirect_to scheme_location_startdate_path(@scheme, @location) + redirect_to scheme_location_availability_path(@scheme, @location) end end - def startdate + def availability if params[:location].present? day = params[:location]["startdate(3i)"] month = params[:location]["startdate(2i)"] @@ -71,7 +71,14 @@ class LocationsController < ApplicationController end end - def check_answers; end + def check_answers + if params[:location].present? + @location.confirmed = true + @location.save! + flash[:notice] = "#{@location.postcode} #{@location.startdate < Time.zone.now ? "has been" : "will be"} added to this scheme" + redirect_to scheme_locations_path(@scheme, @location) + end + end def show; end diff --git a/app/helpers/locations_helper.rb b/app/helpers/locations_helper.rb index 6d797e7fc..1073e18d7 100644 --- a/app/helpers/locations_helper.rb +++ b/app/helpers/locations_helper.rb @@ -32,7 +32,7 @@ module LocationsHelper { name: "Most common unit", value: location.type_of_unit, attribute: "type_of_unit"}, { name: "Mobility standards", value: location.mobility_type, attribute: "mobility_standards" }, { name: "Code", value: location.location_code, attribute: "location_code" }, - { name: "Availability", value: location_availability(location), attribute: "startdate" }, + { name: "Availability", value: location_availability(location), attribute: "availability" }, ] if FeatureToggle.location_toggle_enabled? @@ -67,8 +67,8 @@ module LocationsHelper scheme_location_type_of_unit_path(location.scheme, location, referrer: "check_answers") when "mobility_standards" scheme_location_mobility_standards_path(location.scheme, location, referrer: "check_answers") - when "startdate" - scheme_location_startdate_path(location.scheme, location, referrer: "check_answers") + when "avaliability" + scheme_location_availability_path(location.scheme, location, referrer: "check_answers") end end diff --git a/app/views/locations/startdate.html.erb b/app/views/locations/availability.erb similarity index 89% rename from app/views/locations/startdate.html.erb rename to app/views/locations/availability.erb index 52b39058a..b7659f28d 100644 --- a/app/views/locations/startdate.html.erb +++ b/app/views/locations/availability.erb @@ -7,7 +7,7 @@ ) %> <% end %> -<%= form_for(@location, method: :patch, url: scheme_location_startdate_path(@scheme, @location)) do |f| %> +<%= form_for(@location, method: :patch, url: scheme_location_availability_path(@scheme, @location)) do |f| %>