BathHacked/energy-sparks

View on GitHub
app/views/shared/_school_status_buttons.html.erb

Summary

Maintainability
Test Coverage
<% if can?(:change_visibility, school) %>
  <% if school.visible? %>
    <%= link_to 'Visible', school_visibility_path(school), class: 'badge badge-pill badge-success', method: :delete, data: { confirm: 'Are you sure?' } %>
  <% else %>
    <%= link_to 'Visible', school_visibility_path(school), class: 'badge badge-pill badge-danger', method: :post, data: { confirm: 'Are you sure?' } %>
  <% end %>
<% end %>

<% if can?(:change_public, school) %>
  <% if school.public? %>
    <%= link_to 'Public', school_public_path(school), class: 'badge badge-pill badge-success', method: :delete, data: { confirm: 'Are you sure?' } %>
  <% else %>
    <%= link_to 'Public', school_public_path(school), class: 'badge badge-pill badge-danger', method: :post, data: { confirm: 'Are you sure?' } %>
  <% end %>
<% end %>

<% if can?(:change_data_processing, school) %>
  <% if school.process_data? %>
    <%= link_to 'Process data', school_data_processing_path(school), class: 'badge badge-pill badge-success', method: :delete, data: { confirm: 'Are you sure?' } %>
  <% else %>
    <%= link_to 'Process data', school_data_processing_path(school), class: 'badge badge-pill badge-danger', method: :post, data: { confirm: 'Are you sure?' } %>
  <% end %>
<% end %>

<% if can?(:change_data_enabled, school) %>
  <% if school.data_enabled? %>
    <%= link_to 'Data visible', school_data_enabled_path(school), class: 'badge badge-pill badge-success', method: :delete, data: { confirm: 'Are you sure?' } %>
  <% else %>
    <%= link_to 'Data visible', school_data_enabled_path(school), class: 'badge badge-pill badge-danger', method: :post, data: { confirm: 'Are you sure?' } %>
  <% end %>
<% end %>

<% if can?(:regenerate_school_data, school) %>
  <%= link_to "Regenerate", school_batch_runs_path(school), class: 'badge badge-pill badge-success' %>
<% end %>