From 6d592d14ad352f8cae93e69f639a30b82cdf53c1 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Fri, 19 Jul 2024 16:54:17 +0100 Subject: [PATCH] Separate out active scheme check --- app/models/scheme.rb | 4 ++-- app/views/schemes/_scheme_list.html.erb | 2 +- app/views/schemes/show.html.erb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/scheme.rb b/app/models/scheme.rb index 7ae492c9f..2224ef0e2 100644 --- a/app/models/scheme.rb +++ b/app/models/scheme.rb @@ -296,13 +296,13 @@ class Scheme < ApplicationRecord end def has_active_locations? - active? && locations.active.exists? + locations.active_status.exists? end def has_active_locations_on_date?(date) return false unless date - locations.any? { |location| date && location.active_on_date?(date) } + locations.any? { |location| location.active_on_date?(date) } end def reactivating_soon? diff --git a/app/views/schemes/_scheme_list.html.erb b/app/views/schemes/_scheme_list.html.erb index bb80c6bc1..967295236 100644 --- a/app/views/schemes/_scheme_list.html.erb +++ b/app/views/schemes/_scheme_list.html.erb @@ -28,7 +28,7 @@ <% row.with_cell(text: scheme.locations.visible&.count) %> <% row.with_cell do %> <%= status_tag_from_resource(scheme) %> - <% unless scheme.has_active_locations? %> + <% if scheme.active? && !scheme.has_active_locations? %> <%= content_tag(:div, "No currently active locations", class: "app-!-colour-muted", style: "margin-top: 10px") %> <% end %> <% end %> diff --git a/app/views/schemes/show.html.erb b/app/views/schemes/show.html.erb index ab005e18d..6cefa5847 100644 --- a/app/views/schemes/show.html.erb +++ b/app/views/schemes/show.html.erb @@ -26,7 +26,7 @@