<div id="c-bans">
  <div id="a-index">
    <h1>Bans</h1>

    <%= render "search" %>

    <table class="striped autofit">
      <thead>
        <tr>
          <th>User</th>
          <th>Banner</th>
          <th>Banned</th>
          <th>Duration</th>
          <th>Reason</th>
          <th></th>
        </tr>
      </thead>
      <tbody>
        <% @bans.each do |ban| %>
          <tr id="ban-<%= ban.id %>" data-expired="<%= ban.expired? %>">
            <td>
              <%= link_to_user(ban.user) %>
              <%= link_to "»", bans_path(search: params[:search].merge(user_name: ban.user.name)) %>
            </td>
            <td>
              <%= link_to_user(ban.banner) %>
              <%= link_to "»", bans_path(search: params[:search].merge(banner_name: ban.banner.name)) %>
            </td>
            <td><%= time_ago_in_words_tagged(ban.created_at) %></td>
            <td><%= humanized_duration(ban.created_at, ban.expires_at) %></td>
            <td class="col-expand"><%= format_text ban.reason %></td>
            <td>
              <% if CurrentUser.is_moderator? %>
                <%= link_to "Edit", edit_ban_path(ban) %>
                | <%= link_to "Delete", ban_path(ban), :method => :delete, :remote => true %>
              <% end %>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>

    <%= numbered_paginator(@bans) %>
  </div>
</div>

<%= render "secondary_links" %>

<% content_for(:page_title) do %>
  Bans - <%= Danbooru.config.app_name %>
<% end %>
