Browse Source

handle no open period to reactivate

pull/2995/head
Carolyn 2 months ago
parent
commit
d564b5fc4a
  1. 14
      app/controllers/locations_controller.rb
  2. 13
      app/controllers/schemes_controller.rb

14
app/controllers/locations_controller.rb

@ -210,12 +210,22 @@ class LocationsController < ApplicationController
end end
def new_reactivation def new_reactivation
@location_deactivation_period = @location.location_deactivation_periods.deactivations_without_reactivation.first open_deactivations = @location.location_deactivation_periods.deactivations_without_reactivation
if open_deactivations.blank?
render_not_found and return
end
@location_deactivation_period = open_deactivations.first
render "toggle_active", locals: { action: "reactivate" } render "toggle_active", locals: { action: "reactivate" }
end end
def reactivate def reactivate
@location_deactivation_period = @location.location_deactivation_periods.deactivations_without_reactivation.first open_deactivations = @location.location_deactivation_periods.deactivations_without_reactivation
if open_deactivations.blank?
render_not_found and return
end
@location_deactivation_period = open_deactivations.first
@location_deactivation_period.reactivation_date = toggle_date("reactivation_date") @location_deactivation_period.reactivation_date = toggle_date("reactivation_date")
@location_deactivation_period.reactivation_date_type = params[:location_deactivation_period][:reactivation_date_type] @location_deactivation_period.reactivation_date_type = params[:location_deactivation_period][:reactivation_date_type]

13
app/controllers/schemes_controller.rb

@ -88,13 +88,22 @@ class SchemesController < ApplicationController
end end
def new_reactivation def new_reactivation
@scheme_deactivation_period = @scheme.scheme_deactivation_periods.deactivations_without_reactivation.first open_deactivations = @scheme.scheme_deactivation_periods&.deactivations_without_reactivation
if open_deactivations.blank?
render_not_found and return
end
@scheme_deactivation_period = open_deactivations.first
render "toggle_active", locals: { action: "reactivate" } render "toggle_active", locals: { action: "reactivate" }
end end
def reactivate def reactivate
@scheme_deactivation_period = @scheme.scheme_deactivation_periods.deactivations_without_reactivation.first open_deactivations = @scheme.scheme_deactivation_periods&.deactivations_without_reactivation
if open_deactivations.blank?
render_not_found and return
end
@scheme_deactivation_period = open_deactivations.first
@scheme_deactivation_period.reactivation_date = toggle_date("reactivation_date") @scheme_deactivation_period.reactivation_date = toggle_date("reactivation_date")
@scheme_deactivation_period.reactivation_date_type = params[:scheme_deactivation_period][:reactivation_date_type] @scheme_deactivation_period.reactivation_date_type = params[:scheme_deactivation_period][:reactivation_date_type]

Loading…
Cancel
Save