Browse Source

feat: add activating_soon status to location (not to schemes as they have no startdate field)

pull/1023/head
natdeanlewissoftwire 4 years ago
parent
commit
015332ba78
  1. 2
      app/helpers/tag_helper.rb
  2. 7
      app/models/location.rb

2
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

7
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

Loading…
Cancel
Save