internetee/registry

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

Summary

Maintainability
Test Coverage
- domain = ObjectVersionsParser.new(@version).parse

- if @version
  - children = HashWithIndifferentAccess.new(@version.children)
  - nameservers    = Nameserver.all_versions_for(children[:nameservers], @version.created_at)
  - dnskeys        = Dnskey.all_versions_for(children[:dnskeys], @version.created_at)
  - tech_contacts  = Contact.all_versions_for(children[:tech_contacts], @version.created_at)
  - admin_contacts = Contact.all_versions_for(children[:admin_contacts], @version.created_at)
  - registrant     = Contact.all_versions_for(children[:registrant], @version.created_at)
  - event       = @version.event
  - creator     = plain_username(@version.terminator)

= render 'shared/title', name: domain.name

.row
  .col-md-8
    .panel.panel-default{:style => "min-height:450px;"}
      .panel-heading
        %h3.panel-title
          = l(@version.created_at, format: :short)
          = event
          = creator
      .panel-body
        %dl.dl-horizontal
          %dt= t(:name)
          - if !domain.name
            - domain_name = Domain.find(@version.item_id).try(:name)
          - else
            - domain_name = domain.name
          %dd= link_to(domain_name, admin_domain_path(@version.item_id))

          %dt= t('.created')
          %dd
            = l(domain.created_at, format: :short)

          %dt= t('.updated')
          %dd
            = l(domain.updated_at, format: :short)

          %br

          %dt= t(:statuses)
          %dd{class: changing_css_class(@version,"statuses")}
            - if domain.statuses.present?
              - domain.statuses.each do |s|
                = s

          %dt= "Status notes"
          %dd{class: changing_css_class(@version,"statuses")}
            - if domain.status_notes.present?
              - domain.status_notes.each do |s|
                = s

          %dt= t('.registrant')
          %dd{class: changing_css_class(@version,"registrant_id")}
            - registrant.each do |r|
              - link = r.version_loader ? admin_contact_version_path(r.version_loader.try(:id)) : admin_contact_path(r.id)
              = link_to link, target: "contact_#{r.id}" do
                = r[:name]
                = r[:phone]
                = r[:email]
                = r[:code]
                %br

          %dt= t('.admin_contacts')
          %dd
            - admin_contacts.each do |r|
              - link = r.version_loader ? admin_contact_version_path(r.version_loader.try(:id)) : admin_contact_path(r.id)
              = link_to link, target: "contact_#{r.id}" do
                = r[:name]
                = r[:phone]
                = r[:email]
                = r[:code]
                %br

          %dt= t('.tech_contacts')
          %dd
            - tech_contacts.each do |r|
              - link = r.version_loader ? admin_contact_version_path(r.version_loader.try(:id)) : admin_contact_path(r.id)
              = link_to link, target: "contact_#{r.id}" do
                = r[:name]
                = r[:phone]
                = r[:email]
                = r[:code]
                %br

          %dt= t(:nameservers)
          %dd
            - nameservers.each do |ns|
              = ns[:hostname]
              = ns[:ipv4]
              = ns[:ipv6]
              %br

          %dt= t(:dnskeys)
          %dd
            - dnskeys.each do |ns|
              = ns[:flags]
              = ns[:protocol]
              = ns[:alg]
              - if ns[:public_key].present?
                \...#{ns[:public_key].to_s[-20,20]}
            %br

          - if domain.registrar
            %dt= t(:registrar_name)
            %dd{class: changing_css_class(@version,"registrar_id")}
              = link_to admin_registrar_path(domain.registrar), target: "registrar_#{domain.registrar.id}" do
                = domain.registrar.name
            %span{:style => "margin: 20px 20px; clear:both;"}

        - if (prev = @versions_map[(@versions_map.index(@version.id) - 1)]) && @versions_map.index(@version.id) != 0
          = link_to(t(:previous),
                    admin_domain_version_path(prev),
                    class: 'btn btn-primary')
        - else
          %a.btn.btn-primary.disabled{:href => "#"}
            %span= t(:previous)
        - if nxt = @versions_map[(@versions_map.index(@version.id) + 1)]
          = link_to(t(:next),
                    admin_domain_version_path(nxt),
                    class: 'btn btn-default')
        - else
          %a.btn.btn-default.disabled{:href => "#"}
            %span= t(:next)

  .col-md-4
    .panel.panel-default{:style => "min-height:450px;"}
      %ul.nav.nav-pills.nav-stacked
        - @versions.each do |vs|
          %li{class: (vs.id == @version.id) && :active}
            = link_to admin_domain_version_path(vs) do
              = l(vs.created_at, format: :short)
              = vs.event
      %span{:style => "padding-left:10px; position: absolute; bottom: 10px;"}
        = paginate @versions