|
|
|
|
@ -20,8 +20,9 @@ class LocationsController < ApplicationController
|
|
|
|
|
redirect_to scheme_location_postcode_path(@scheme, @location, route: params[:route]) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def postcode |
|
|
|
|
if params[:location].present? |
|
|
|
|
def postcode; end |
|
|
|
|
|
|
|
|
|
def update_postcode |
|
|
|
|
@location.postcode = PostcodeService.clean(params[:location][:postcode]) |
|
|
|
|
if @location.postcode_changed? |
|
|
|
|
@location.location_admin_district = nil |
|
|
|
|
@ -39,10 +40,10 @@ class LocationsController < ApplicationController
|
|
|
|
|
render :postcode, status: :unprocessable_entity |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def local_authority |
|
|
|
|
if params[:location].present? |
|
|
|
|
def local_authority; end |
|
|
|
|
|
|
|
|
|
def update_local_authority |
|
|
|
|
@location.location_admin_district = params[:location][:location_admin_district] |
|
|
|
|
@location.location_code = Location.local_authorities.key(params[:location][:location_admin_district]) |
|
|
|
|
if @location.save(context: :location_admin_district) |
|
|
|
|
@ -55,10 +56,10 @@ class LocationsController < ApplicationController
|
|
|
|
|
render :local_authority, status: :unprocessable_entity |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def name |
|
|
|
|
if params[:location].present? |
|
|
|
|
def name; end |
|
|
|
|
|
|
|
|
|
def update_name |
|
|
|
|
@location.name = params[:location][:name] |
|
|
|
|
if @location.save(context: :name) |
|
|
|
|
case params[:referrer] |
|
|
|
|
@ -73,10 +74,10 @@ class LocationsController < ApplicationController
|
|
|
|
|
render :name, status: :unprocessable_entity |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def units |
|
|
|
|
if params[:location].present? |
|
|
|
|
def units; end |
|
|
|
|
|
|
|
|
|
def update_units |
|
|
|
|
@location.units = params[:location][:units] |
|
|
|
|
if @location.save(context: :units) |
|
|
|
|
if params[:referrer] == "check_answers" |
|
|
|
|
@ -88,10 +89,10 @@ class LocationsController < ApplicationController
|
|
|
|
|
render :units, status: :unprocessable_entity |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def type_of_unit |
|
|
|
|
if params[:location].present? |
|
|
|
|
def type_of_unit; end |
|
|
|
|
|
|
|
|
|
def update_type_of_unit |
|
|
|
|
@location.type_of_unit = params[:location][:type_of_unit] |
|
|
|
|
if @location.save(context: :type_of_unit) |
|
|
|
|
if params[:referrer] == "check_answers" |
|
|
|
|
@ -103,10 +104,10 @@ class LocationsController < ApplicationController
|
|
|
|
|
render :type_of_unit, status: :unprocessable_entity |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def mobility_standards |
|
|
|
|
if params[:location].present? |
|
|
|
|
def mobility_standards; end |
|
|
|
|
|
|
|
|
|
def update_mobility_standards |
|
|
|
|
@location.mobility_type = params[:location][:mobility_type] |
|
|
|
|
if @location.save(context: :mobility_type) |
|
|
|
|
if params[:referrer] == "check_answers" |
|
|
|
|
@ -118,10 +119,10 @@ class LocationsController < ApplicationController
|
|
|
|
|
render :mobility_standards, status: :unprocessable_entity |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def availability |
|
|
|
|
if params[:location].present? |
|
|
|
|
def availability; end |
|
|
|
|
|
|
|
|
|
def update_availability |
|
|
|
|
day = params[:location]["startdate(3i)"] |
|
|
|
|
month = params[:location]["startdate(2i)"] |
|
|
|
|
year = params[:location]["startdate(1i)"] |
|
|
|
|
@ -144,16 +145,15 @@ class LocationsController < ApplicationController
|
|
|
|
|
render :availability, status: :unprocessable_entity |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def check_answers |
|
|
|
|
if params[:location].present? |
|
|
|
|
def check_answers; end |
|
|
|
|
|
|
|
|
|
def update_check_answers |
|
|
|
|
@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) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def show; end |
|
|
|
|
|
|
|
|
|
|