Browse Source

refactor: move location helper methods to helpers

pull/1455/head
natdeanlewissoftwire 3 years ago
parent
commit
72691077e8
  1. 4
      app/controllers/locations_controller.rb
  2. 6
      app/helpers/locations_helper.rb

4
app/controllers/locations_controller.rb

@ -134,9 +134,7 @@ class LocationsController < ApplicationController
def check_answers; end
def confirm
if @location.confirmed
flash[:notice] = "#{@location.postcode} #{@location.startdate.blank? || @location.startdate < Time.zone.now ? 'has been' : 'will be'} added to this scheme"
end
flash[:notice] = helpers.location_creation_success_notice(@location)
redirect_to scheme_locations_path(@scheme)
end

6
app/helpers/locations_helper.rb

@ -78,6 +78,12 @@ module LocationsHelper
return govuk_button_link_to "Reactivate this location", scheme_location_new_reactivation_path(location.scheme, location) if location.deactivated?
end
def location_creation_success_notice(location)
if location.confirmed
"#{location.postcode} #{location.startdate.blank? || location.startdate < Time.zone.now ? 'has been' : 'will be'} added to this scheme"
end
end
private
ActivePeriod = Struct.new(:from, :to)

Loading…
Cancel
Save