Browse Source

refactor: respond to PR comments 2

pull/980/head
natdeanlewissoftwire 2 years ago
parent
commit
35fd5d074f
  1. 4
      app/models/location.rb
  2. 4
      app/models/scheme.rb
  3. 2
      app/views/locations/show.html.erb
  4. 2
      app/views/schemes/show.html.erb

4
app/models/location.rb

@ -378,6 +378,10 @@ class Location < ApplicationRecord
return :deactivated if Time.zone.now >= deactivation_date return :deactivated if Time.zone.now >= deactivation_date
end end
def active?
status == :active
end
private private
PIO = PostcodeService.new PIO = PostcodeService.new

4
app/models/scheme.rb

@ -219,4 +219,8 @@ class Scheme < ApplicationRecord
return :deactivates_soon if Time.zone.now < deactivation_date return :deactivates_soon if Time.zone.now < deactivation_date
return :deactivated if Time.zone.now >= deactivation_date return :deactivated if Time.zone.now >= deactivation_date
end end
def active?
status == :active
end
end end

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

@ -24,7 +24,7 @@
</div> </div>
</div> </div>
<% if FeatureToggle.location_toggle_enabled? %> <% if FeatureToggle.location_toggle_enabled? %>
<% if @location.status == :active %> <% if @location.active? %>
<%= govuk_button_link_to "Deactivate this location", scheme_location_deactivate_path(scheme_id: @scheme.id, location_id: @location.id), warning: true %> <%= govuk_button_link_to "Deactivate this location", scheme_location_deactivate_path(scheme_id: @scheme.id, location_id: @location.id), warning: true %>
<% else %> <% else %>
<%= govuk_button_link_to "Reactivate this location", scheme_location_reactivate_path(scheme_id: @scheme.id, location_id: @location.id) %> <%= govuk_button_link_to "Reactivate this location", scheme_location_reactivate_path(scheme_id: @scheme.id, location_id: @location.id) %>

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

@ -26,7 +26,7 @@
<% end %> <% end %>
<% if FeatureToggle.scheme_toggle_enabled? %> <% if FeatureToggle.scheme_toggle_enabled? %>
<% if @scheme.status == :active %> <% if @scheme.active? %>
<%= govuk_button_link_to "Deactivate this scheme", scheme_deactivate_path(@scheme), warning: true %> <%= govuk_button_link_to "Deactivate this scheme", scheme_deactivate_path(@scheme), warning: true %>
<% else %> <% else %>
<%= govuk_button_link_to "Reactivate this scheme", scheme_reactivate_path(@scheme) %> <%= govuk_button_link_to "Reactivate this scheme", scheme_reactivate_path(@scheme) %>

Loading…
Cancel
Save