From 35fd5d074fffabb45738e1893b7f54b593bc191f Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Mon, 14 Nov 2022 14:21:25 +0000 Subject: [PATCH] refactor: respond to PR comments 2 --- app/models/location.rb | 4 ++++ app/models/scheme.rb | 4 ++++ app/views/locations/show.html.erb | 2 +- app/views/schemes/show.html.erb | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/models/location.rb b/app/models/location.rb index 4fb49e7c6..a6b044cfa 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -378,6 +378,10 @@ class Location < ApplicationRecord return :deactivated if Time.zone.now >= deactivation_date end + def active? + status == :active + end + private PIO = PostcodeService.new diff --git a/app/models/scheme.rb b/app/models/scheme.rb index eaa6bce3d..0b3258255 100644 --- a/app/models/scheme.rb +++ b/app/models/scheme.rb @@ -219,4 +219,8 @@ class Scheme < ApplicationRecord return :deactivates_soon if Time.zone.now < deactivation_date return :deactivated if Time.zone.now >= deactivation_date end + + def active? + status == :active + end end diff --git a/app/views/locations/show.html.erb b/app/views/locations/show.html.erb index 61a05f3ac..8b7ae9e0c 100644 --- a/app/views/locations/show.html.erb +++ b/app/views/locations/show.html.erb @@ -24,7 +24,7 @@ <% if FeatureToggle.location_toggle_enabled? %> - <% if @location.status == :active %> + <% if @location.active? %> <%= govuk_button_link_to "Deactivate this location", scheme_location_deactivate_path(scheme_id: @scheme.id, location_id: @location.id), warning: true %> <% else %> <%= govuk_button_link_to "Reactivate this location", scheme_location_reactivate_path(scheme_id: @scheme.id, location_id: @location.id) %> diff --git a/app/views/schemes/show.html.erb b/app/views/schemes/show.html.erb index de80e8897..ff8a25c0a 100644 --- a/app/views/schemes/show.html.erb +++ b/app/views/schemes/show.html.erb @@ -26,7 +26,7 @@ <% end %> <% if FeatureToggle.scheme_toggle_enabled? %> - <% if @scheme.status == :active %> + <% if @scheme.active? %> <%= govuk_button_link_to "Deactivate this scheme", scheme_deactivate_path(@scheme), warning: true %> <% else %> <%= govuk_button_link_to "Reactivate this scheme", scheme_reactivate_path(@scheme) %>