rtopitt/bolao2014

View on GitHub
app/views/bets/index.html.erb

Summary

Maintainability
Test Coverage
<% content_for(:title) { t('.title') } %>

<div class="row">
  <div class="small-12 column">
    <h2><%= Bet.model_name.human(count: 2) %></h2>
  </div>
</div>

<div class="row">
  <div class="small-9 column">
    <h3><%= t('.general_classification') %></h3>
    <table>
      <thead>
        <tr>
          <th class="hide-for-small-only"><%= t('.ranking') %></th>
          <th><%= t('.user') %></th>
          <th class="hide-for-small-only"><%= t('.completeness') %></th>
          <th class="hide-for-small-only"><%= t('.payment') %></th>
          <th><%= t('.points') %></th>
          <th>&nbsp;</th>
        </tr>
      </thead>
      <tbody>
        <% index, previous_points = 0, nil %>
        <% @bets.each do |bet| %>
          <% index += 1 if previous_points != bet.points %>
          <% previous_points = bet.points %>
          <tr>
            <td class="hide-for-small-only"><%= index %>º</td>
            <td><%= bet.user.name_or_email %></td>
            <td class="hide-for-small-only"><%= bet.percentage %></td>
            <td class="hide-for-small-only"><%= bet.payment_status %></td>
            <td><%= bet.points %></td>
            <td><%= link_to t('.view'), bet_path(bet) %></td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
  <div class="small-3 column">
    <h3><%= t('.prizes') %></h3>
    <% bet = @bets.first %>
    <ul>
      <li>
        <%= t('.paid_bets') %>: <%= @paid_bets_count %>
        <% if @paying_bets_count > 0 %>
          <ul>
            <li><%= t('.paying_bets') %>: <%= @paying_bets_count %></li>
          </ul>
        <% end %>
      </li>
      <% if @paid_bets_count > 0 %>
        <li>1º <%= t('.place') %>: <%= number_to_currency ((bet.prize_split[:first] / 100.0) * @paid_bets_count * bet.to_prize) %></li>
        <li>2º <%= t('.place') %>: <%= number_to_currency ((bet.prize_split[:second] / 100.0) * @paid_bets_count * bet.to_prize) %></li>
        <li>3º <%= t('.place') %>: <%= number_to_currency ((bet.prize_split[:third] / 100.0) * @paid_bets_count * bet.to_prize) %></li>
      <% end %>
    </ul>
    <p><%= t('.if_doubt_see_rules', the_rules_link: link_to(t('.the_rules'), help_path)).html_safe %></p>
  </div>
</div>