diff --git a/app/models/scheme.rb b/app/models/scheme.rb index 07f4f8c9f..342327636 100644 --- a/app/models/scheme.rb +++ b/app/models/scheme.rb @@ -295,8 +295,8 @@ class Scheme < ApplicationRecord status == :active end - def all_locations_inactive? - active? && locations.all? { |location| !location.active? } + def has_active_locations? + active? && locations.active.exists? end def any_location_active_on_date?(date) diff --git a/app/views/schemes/_scheme_list.html.erb b/app/views/schemes/_scheme_list.html.erb index 2317b038b..bb80c6bc1 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) %> - <% if scheme.all_locations_inactive? %> + <% unless 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 d8f31fd37..ab005e18d 100644 --- a/app/views/schemes/show.html.erb +++ b/app/views/schemes/show.html.erb @@ -26,7 +26,7 @@
Status
<%= details_html({ name: "Status", value: status_tag_from_resource(@scheme), id: "status" }) %> - <% if @scheme.confirmed? && @scheme.all_locations_inactive? %> + <% if @scheme.confirmed? && !@scheme.has_active_locations? %> No currently active locations <% end %> <% if @scheme.confirmed? && @scheme.locations.confirmed.none? && LocationPolicy.new(current_user, @scheme.locations.new).create? %>