internetee/registry

View on GitHub
app/views/admin/registrars/index.html.erb

Summary

Maintainability
Test Coverage
<div class="page-header">
    <div class="row">
        <div class="col-sm-10">
            <h1><%= t '.header' %></h1>
        </div>

        <div class="col-sm-2 text-right">
            <%= link_to t('.new_btn'), new_admin_registrar_path, class: 'btn btn-primary' %>
        </div>
    </div>
</div>

<%= render 'search_form', search: @search %>

<div class="row">
    <div class="col-md-12">
        <div class="table-responsive">
            <table class="table table-hover table-bordered table-condensed">
                <thead>
                <tr>
                    <th class="col-xs-4">
                        <%= sort_link(@q, 'name') %>
                    </th>
                    <th class="col-xs-4">
                        <%= sort_link(@q, 'reg_no', Registrar.human_attribute_name(:reg_no)) %>
                    </th>
                    <th class="col-xs-4">
                        <%= Registrar.human_attribute_name :balance %>
                    </th>
                    <th class="col-xs-4">
                        <%= t(:test_registrar) %>
                    </th>
                    <th class="col-xs-4">
                        <%= t(:emails) %>
                    </th>
                    </th>
                    <th>
                        Test status
                    </th>
                </tr>
                </thead>
                <tbody>
                <% @registrars.each do |x| %>
                    <tr>
                        <td>
                            <%= link_to(x, [:admin, x]) %>
                        </td>
                        <td>
                            <%= x.reg_no %>
                        </td>
                        <% if x.cash_account.present? %>
                            <td>
                                <%= link_to "#{x.balance}", edit_admin_account_path(x.cash_account) %>
                            </td>
                        <% end %>
                        <td>
                            <%= "#{x.test_registrar}" %>
                        </td>
                        <td>
                            <%= content_tag(:span, x.email) %>
                            <% if x[:billing_email].present? %>
                                <%= content_tag(:span, x[:billing_email]) %>
                            <% end %>
                        </td>
                        <td>
                            <% if !x.accredited? || x.accreditation_expired? %>
                                <%= button_to t(:set_test_btn),
                                              { controller: 'registrars', action: 'set_test_date', registrar_id: x.id},
                                              { method: :post, class: 'btn btn-primary'} %>
                            <% else %>
                                <%= button_to t(:remove_test_btn),
                                              { controller: 'registrars', action: 'remove_test_date', registrar_id: x.id},
                                              { method: :post, class: 'btn btn-danger'} %>
                            <% end %>
                        </td>
                    </tr>
                <% end %>
                </tbody>
            </table>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-md-6">
        <%= paginate @registrars %>
    </div>
    <div class="col-md-6 text-right">
        <div class="pagination">
            <%= t(:result_count, count: @registrars.total_count) %>
        </div>
    </div>
</div>