Browse Source

Separate out active scheme check

pull/2510/head
Manny Dinssa 2 years ago
parent
commit
6d592d14ad
  1. 4
      app/models/scheme.rb
  2. 2
      app/views/schemes/_scheme_list.html.erb
  3. 2
      app/views/schemes/show.html.erb

4
app/models/scheme.rb

@ -296,13 +296,13 @@ class Scheme < ApplicationRecord
end end
def has_active_locations? def has_active_locations?
active? && locations.active.exists? locations.active_status.exists?
end end
def has_active_locations_on_date?(date) def has_active_locations_on_date?(date)
return false unless date return false unless date
locations.any? { |location| date && location.active_on_date?(date) } locations.any? { |location| location.active_on_date?(date) }
end end
def reactivating_soon? def reactivating_soon?

2
app/views/schemes/_scheme_list.html.erb

@ -28,7 +28,7 @@
<% row.with_cell(text: scheme.locations.visible&.count) %> <% row.with_cell(text: scheme.locations.visible&.count) %>
<% row.with_cell do %> <% row.with_cell do %>
<%= status_tag_from_resource(scheme) %> <%= 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") %> <%= content_tag(:div, "No currently active locations", class: "app-!-colour-muted", style: "margin-top: 10px") %>
<% end %> <% end %>
<% end %> <% end %>

2
app/views/schemes/show.html.erb

@ -26,7 +26,7 @@
<dt class="govuk-summary-list__key">Status</dt> <dt class="govuk-summary-list__key">Status</dt>
<dd class="govuk-summary-list__value"> <dd class="govuk-summary-list__value">
<%= details_html({ name: "Status", value: status_tag_from_resource(@scheme), id: "status" }) %> <%= details_html({ name: "Status", value: status_tag_from_resource(@scheme), id: "status" }) %>
<% if @scheme.confirmed? && !@scheme.has_active_locations? %> <% if @scheme.confirmed? && @scheme.active? && !@scheme.has_active_locations? %>
<span class="app-!-colour-muted">No currently active locations</span> <span class="app-!-colour-muted">No currently active locations</span>
<% end %> <% end %>
<% if @scheme.confirmed? && @scheme.locations.confirmed.none? && LocationPolicy.new(current_user, @scheme.locations.new).create? %> <% if @scheme.confirmed? && @scheme.locations.confirmed.none? && LocationPolicy.new(current_user, @scheme.locations.new).create? %>

Loading…
Cancel
Save