From 015332ba78e4fc3add949da386f3a1429e8fcd5d Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Wed, 23 Nov 2022 15:22:35 +0000 Subject: [PATCH] feat: add activating_soon status to location (not to schemes as they have no startdate field) --- app/helpers/tag_helper.rb | 2 ++ app/models/location.rb | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/helpers/tag_helper.rb b/app/helpers/tag_helper.rb index 6682f97fd..f8b19dd83 100644 --- a/app/helpers/tag_helper.rb +++ b/app/helpers/tag_helper.rb @@ -9,6 +9,7 @@ module TagHelper active: "Active", incomplete: "Incomplete", deactivating_soon: "Deactivating soon", + activating_soon: "Activating soon", reactivating_soon: "Reactivating soon", deactivated: "Deactivated", }.freeze @@ -21,6 +22,7 @@ module TagHelper active: "green", incomplete: "red", deactivating_soon: "yellow", + activating_soon: "blue", reactivating_soon: "blue", deactivated: "grey", }.freeze diff --git a/app/models/location.rb b/app/models/location.rb index c05a2351b..7907c1d1b 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -379,7 +379,12 @@ class Location < ApplicationRecord return :deactivated if open_deactivation&.deactivation_date.present? && Time.zone.now >= open_deactivation.deactivation_date return :deactivating_soon if open_deactivation&.deactivation_date.present? && Time.zone.now < open_deactivation.deactivation_date - return :reactivating_soon if recent_deactivation&.reactivation_date.present? && Time.zone.now < recent_deactivation.reactivation_date + + if recent_deactivation&.reactivation_date.present? && Time.zone.now < recent_deactivation.reactivation_date + return :activating_soon if Time.zone.now < startdate + + return :reactivating_soon + end :active end