internetee/registry

View on GitHub
app/views/admin/certificates/show.haml

Summary

Maintainability
Test Coverage
- content_for :actions do
  = link_to(t(:delete), '#', "data-toggle": "modal", "data-target": "#deleteModal", class: 'btn btn-danger')
= render 'shared/title', name: t(:certificates)

.row
  .col-md-12
    .panel.panel-default
      .panel-heading.clearfix
        .pull-left
          = t(:general)

      .panel-body
        %dl.dl-horizontal
          %dt= t(:api_user)
          %dd= link_to(@certificate.api_user, [:admin, @api_user.registrar, @api_user])

          %dt= t(:common_name)
          %dd= @certificate.common_name

          %dt= t(:md5)
          %dd= @certificate.md5

          %dt= t(:interface)
          %dd= @certificate.interface.try(:upcase)

          %dt= t(:updated_at)
          %dd= l(@certificate.updated_at)

          %dt= t(:created_at)
          %dd= l(@certificate.created_at)

- if @csr
  .row
    .col-md-12
      .panel.panel-default
        .panel-heading.clearfix
          .pull-left
            = t(:csr)
          .pull-right
            = link_to(t(:download), download_csr_admin_api_user_certificate_path(@api_user, @certificate), class: 'btn btn-default btn-xs')
            - unless @crt
              - sign_revoke_url = sign_admin_api_user_certificate_path(@api_user, @certificate)
              = link_to(t(:sign_this_request), '#', "data-toggle": "modal", "data-target": "#signRevokeModal", class: 'btn btn-primary btn-xs')

        .panel-body
          %dl.dl-horizontal
            %dt= t(:version)
            %dd= @csr.version

            %dt= CertificationRequest.human_attribute_name :subject
            %dd{ style: 'word-break:break-all;' }= @csr.subject

            %dt= t(:signature_algorithm)
            %dd= @csr.signature_algorithm

- if @crt
  .row
    .col-md-12
      .panel.panel-default
        .panel-heading.clearfix
          .pull-left
            = t('crt') unless @certificate.revoked?
            = t('crt_revoked') if @certificate.revoked?
          .pull-right
            = link_to(t(:download), download_crt_admin_api_user_certificate_path(@api_user, @certificate), class: 'btn btn-default btn-xs')
            - if !@certificate.revoked? && @certificate.csr
              - sign_revoke_url = revoke_admin_api_user_certificate_path(@api_user, @certificate)
              = link_to(t(:revoke_this_certificate), '#', "data-toggle": "modal", "data-target": "#signRevokeModal", class: 'btn btn-primary btn-xs')
        - if @crt
          .panel-body
            %dl.dl-horizontal
              %dt= t(:version)
              %dd= @crt.version

              %dt= Certificate.human_attribute_name :serial_number
              %dd= @crt.serial

              %dt= t(:signature_algorithm)
              %dd= @crt.signature_algorithm

              %dt= t(:issuer)
              %dd= @crt.issuer

              %dt= t(:valid_from)
              %dd= @crt.not_before

              %dt= t(:valid_to)
              %dd= @crt.not_after

              %dt= Certificate.human_attribute_name :subject
              %dd= @crt.subject

              %dt= Certificate.human_attribute_name :extensions
              %dd= @crt.extensions.map(&:to_s).join('<br>').html_safe

.modal.fade{ id: "signRevokeModal", tabindex: "-1", role: "dialog", "aria-labelledby": "signRevokeModalLabel" }
  .modal-dialog{ role: "document" }
    .modal-content
      = form_for(:certificate, url: sign_revoke_url) do |f|
        .modal-header
          %button.close{ type: "button", "data-dismiss": "modal", "aria-label": "Close" }
            %span{ "aria-hidden" => "true" } &times;
          %h4.modal-title{ id: "signRevokeModalLabel" }
            = t(:enter_ca_key_password)
        .modal-body
          = f.password_field :password, required: true, class: 'form-control'
        .modal-footer
          %button.btn.btn-default{ type: "button", "data-dismiss": "modal" }
            = t(:close)
          %button.btn.btn-primary{ type: "submit" }
            = @crt.nil? ? t(:sign) : t(:submit)

.modal.fade{ id: "deleteModal", tabindex: "-1", role: "dialog", "aria-labelledby": "deleteModalLabel" }
  .modal-dialog{ role: "document" }
    .modal-content
      = form_for(:certificate, url: admin_api_user_certificate_path(@api_user, @certificate), method: :delete) do |f|
        .modal-header
          %button.close{ type: "button", "data-dismiss": "modal", "aria-label": "Close" }
            %span{ "aria-hidden" => "true" } &times;
          %h4.modal-title{ id: "deleteModalLabel" }
            = t(:enter_ca_key_password)
        .modal-body
          = f.password_field :password, required: true, class: 'form-control'
        .modal-footer
          %button.btn.btn-default{ type: "button", "data-dismiss": "modal" }
            = t(:close)
          %button.btn.btn-primary{ type: "submit" }
            = t(:delete)