internetee/registry

View on GitHub
app/views/admin/api_users/show/_certificates.html.erb

Summary

Maintainability
Test Coverage
<div class="panel panel-default">
    <div class="panel-heading clearfix">
        <div class="pull-left">
            <%= t(:certificates) %>
        </div>

        <div class="pull-right">
            <%= link_to(t(:upload_crt), new_admin_api_user_certificate_path(@api_user, crt: true), class: 'btn btn-primary btn-xs') %>
            <%= link_to(t(:upload_csr), new_admin_api_user_certificate_path(@api_user), class: 'btn btn-primary btn-xs') %>
        </div>
    </div>

    <div class="table-responsive">
        <table class="table table-hover table-bordered table-condensed">
            <thead>
                <tr>
                    <th class="col-xs-10">
                        <%= t('.subject') %>
                    </th>
                    <th class="col-xs-2">
                        <%= t(:status) %>
                    </th>
                </tr>
            </thead>

            <tbody>
                <% @api_user.certificates.each do |x| %>
                    <% if x.csr %>
                        <tr>
                            <td>
                                <%= link_to(x.parsed_csr.try(:subject),
                                            admin_api_user_certificate_path(@api_user,
                                                                            x)) %>
                            </td>
                            <td>
                                <%= x.status %>
                            </td>
                        </tr>
                    <% elsif x.crt %>
                        <tr>
                            <td>
                                <%= link_to(x.parsed_crt.try(:subject),
                                            admin_api_user_certificate_path(@api_user,
                                                                            x)) %>
                            </td>
                            <td>
                                <%= x.status %>
                            </td>
                        </tr>
                    <% end %>
                <% end %>
            </tbody>
        </table>
    </div>
</div>