roseweixel/lacquer-lover

View on GitHub
app/views/users/_active_requested_transactions.html.erb

Summary

Maintainability
Test Coverage
<% user.active_requested_transactions.each do |transaction| %>
  <% friend = User.find(transaction.owner_id) %>
  <% lacquer = Lacquer.find(transaction.user_lacquer.lacquer_id) %>
  <p class="list-group-item" style='padding-top: 15px;'>
    <%= link_to friend.name, user_path(friend) %> gave you <%= link_to lacquer.name, lacquer_path(lacquer) %> on <%= transaction.date_became_active.strftime("%m/%d/%Y") %>.
    <% if transaction.due_date %>
      <br>
      <% if transaction.overdue? %>
        <span class="alert alert-danger" role="alert" style="padding: 2px;">
        You're <%= pluralize(transaction.days_overdue, 'day') %> overdue to return this lacquer. Don't mess with karma - give it back!
        </span>
      <% elsif transaction.due_today? %>
      <span class="alert alert-dismissable alert-warning" style="padding: 2px;">
  
        Remember to give this lacquer back <strong>today</strong>!
      </span>
      <% elsif transaction.due_tomorrow? %>
      <span class="alert alert-dismissable alert-success" style="padding: 2px;">
        Remember to give this lacquer back <strong>tomorrow</strong>!
      </span>
      <% end %>
      <br>
      <span>
      The return date for this loan is <span class="due-date"><%= transaction.due_date.strftime("%m/%d/%Y") %></span>.
      </span>
    <% end %>
    <br>
    <%= link_to 'I gave it back', transaction_path(transaction, :state => 'returned_unconfirmed'), {:method => "PATCH", class: "btn btn-success btn-xs", data: {confirm: "Continue only if you have given #{transaction.lacquer.name} back to #{transaction.owner.first_name}. Are you sure?"}} %>
    <br>
    <br>
    <%= link_to "send #{friend.first_name} a message", new_transactional_message_path(:transaction_id => transaction.id) %>
  </p>
<% end %>