internetee/registry

View on GitHub
app/views/admin/registrars/show/_api_users.html.erb

Summary

Maintainability
Test Coverage
<div class="panel panel-default api_users">
    <div class="panel-heading">
        <%= t '.header' %>
    </div>

    <table class="table table-hover table-bordered table-condensed">
        <thead>
            <tr>
                <th class="col-xs-6"><%= ApiUser.human_attribute_name :username %></th>
                <th class="col-xs-6"><%= ApiUser.human_attribute_name :active %></th>
                <th class="col-xs-6">Test Results</th>
            </tr>
        </thead>

        <tbody>
            <% registrar.api_users.each do |api_user| %>
                <tr>
                    <td><%= link_to api_user, admin_registrar_api_user_path(registrar, api_user) %></td>
                    <td><%= api_user.active %></td>
                    <td>

                        <% if !api_user.accredited? || api_user.accreditation_expired? %>
                            <%= button_to t('.set_test_btn'),
                                          { controller: 'api_users', action: 'set_test_date_to_api_user', user_api_id: api_user.id },
                                          { method: :post, class: 'btn btn-primary'} %>
                        <% else %>
                            <%= button_to t('.remove_test_btn'),
                                          { controller: 'api_users', action: 'remove_test_date_to_api_user', user_api_id: api_user.id },
                                          { method: :post, class: 'btn btn-danger'} %>
                        <% end %>
                    </td>
                </tr>
            <% end %>
        </tbody>
    </table>

    <div class="panel-footer text-right">
        <%= link_to t('.new_btn'), new_admin_registrar_api_user_path(registrar),
                    class: 'btn btn-default btn-xs' %>
        <%= link_to 'Export to CSV', export_admin_registrar_path(registrar, records: 'api_users', format: :csv),
                    class: 'btn btn-default btn-xs' if registrar.api_users.any? %>
    </div>
</div>