holderdeord/hdo-site

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

Summary

Maintainability
Test Coverage
<% if votes.any? %>
  <table id="votes" class="table table-striped">
    <thead>
      <tr>
        <th class="wide-table-header"><%= Vote.human_attribute_name :external_id %></th>
        <th class="wide-table-header"><%= Vote.human_attribute_name :time %></th>
        <% if show_issues %>
          <th><%= ParliamentIssue.model_name.human(count: 2).capitalize %></th>
        <% end %>
        <th><%= Vote.human_attribute_name :subject %></th>
        <th><%= Vote.human_attribute_name :enacted %></th>
        <th class="wide-table-header"><%= Vote.human_attribute_name :for_count %></th>
        <th class="wide-table-header"><%= Vote.human_attribute_name :against_count %></th>
        <th class="wide-table-header"><%= Vote.human_attribute_name :absent_count %></th>
      </tr>
    </thead>
    <tbody>
      <% votes.each do |vote| %>
      <tr>
        <td><%= vote.external_id %></td>
        <td><%= l vote.time.localtime, format: :short_text %></td>
        <% if show_issues %>
          <td>
            <ul>
              <%- vote.parliament_issues.each do |parliament_issue| -%>
              <li><%= link_to parliament_issue.summary, parliament_issue %></li>
              <%- end -%>
            </ul>

          </td>
        <% end %>
        <td><%= link_to vote.subject, vote %></td>
        <td><%= vote.enacted_text %></td>

        <% stats = vote.stats %>
        <td class="vote-for"><%= stats.for_percent %>% (<%= stats.for_count %>/<%= stats.vote_count %>)</td>
        <td class="vote-against"><%= stats.against_percent %>% (<%= stats.against_count %>/<%= stats.vote_count %>)</td>
        <td class="vote-absent"><%= stats.absent_percent %>% (<%= vote.absent_count %>/<%= stats.total_count %>)</td>
      </tr>
      <% end %>
    </tbody>
  </table>
<% end %>