mirror of
https://github.com/internetee/registry.git
synced 2025-08-01 07:26:22 +02:00
Download pdf with domain data
This commit is contained in:
parent
8238b329e3
commit
318dec4f52
5 changed files with 331 additions and 3 deletions
|
@ -2,7 +2,7 @@ module Admin
|
|||
class DomainsController < BaseController
|
||||
DEFAULT_VERSIONS_PER_PAGE = 10
|
||||
|
||||
before_action :set_domain, only: %i[show edit update keep]
|
||||
before_action :set_domain, only: %i[show edit update download keep]
|
||||
authorize_resource
|
||||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
|
@ -65,6 +65,11 @@ module Admin
|
|||
.per(DEFAULT_VERSIONS_PER_PAGE)
|
||||
end
|
||||
|
||||
def download
|
||||
filename = "#{@domain.name}.pdf"
|
||||
send_data @domain.as_pdf, filename: filename
|
||||
end
|
||||
|
||||
def keep
|
||||
@domain.keep
|
||||
redirect_to edit_admin_domain_url(@domain), notice: t('.kept')
|
||||
|
|
|
@ -740,6 +740,12 @@ class Domain < ApplicationRecord
|
|||
]
|
||||
end
|
||||
|
||||
def as_pdf
|
||||
domain_html = ApplicationController.render(template: 'domain/pdf', assigns: { domain: self })
|
||||
generator = PDFKit.new(domain_html)
|
||||
generator.to_pdf
|
||||
end
|
||||
|
||||
def registrant_name
|
||||
return registrant.name if registrant
|
||||
|
||||
|
|
|
@ -6,11 +6,12 @@
|
|||
|
||||
<div class="page-header">
|
||||
<div class="row">
|
||||
<div class="col-sm-8">
|
||||
<div class="col-sm-7">
|
||||
<h1><%= domain.name_with_status %></h1>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4 text-right">
|
||||
<div class="col-sm-5 text-right">
|
||||
<%= link_to t('.download'), download_admin_domain_path(@domain), class: 'btn btn-primary' %>
|
||||
<%= link_to t('.edit_btn'), edit_admin_domain_path(@domain), class: 'btn btn-primary' %>
|
||||
<%= link_to t('.history_btn'), admin_domain_domain_versions_path(@domain),
|
||||
class: 'btn btn-primary' %>
|
||||
|
|
315
app/views/domain/pdf.haml
Normal file
315
app/views/domain/pdf.haml
Normal file
|
@ -0,0 +1,315 @@
|
|||
%html{lang: I18n.locale.to_s}
|
||||
%head
|
||||
%meta{charset: "utf-8"}
|
||||
:css
|
||||
.container {
|
||||
margin: auto;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.col-md-12 {
|
||||
|
||||
}
|
||||
|
||||
.col-md-6 {
|
||||
width: 49%;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.col-xs-4 {
|
||||
width: 33%;
|
||||
}
|
||||
|
||||
.col-xs-2 {
|
||||
width: 16%;
|
||||
}
|
||||
|
||||
.col-md-3 {
|
||||
width: 24%;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.left {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.left {
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
.right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.text-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
dt {
|
||||
float: left;
|
||||
width: 100px;
|
||||
clear: left;
|
||||
text-align: right;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-weight: bold;
|
||||
line-height: 1.42857;
|
||||
}
|
||||
|
||||
dd {
|
||||
margin-left: 120px;
|
||||
line-height: 1.42857;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
th {
|
||||
text-align: left;
|
||||
border: 0px;
|
||||
border-top: 1px solid #DDD;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
thead th {
|
||||
border-bottom: 2px solid #DDD;
|
||||
border-top: 0px;
|
||||
}
|
||||
|
||||
td {
|
||||
border-top: 1px solid #DDD;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
.no-border {
|
||||
border: 0px;
|
||||
}
|
||||
|
||||
hr {
|
||||
height: 1px;
|
||||
border: 0;
|
||||
color: #DDD;
|
||||
background-color: #DDD;
|
||||
}
|
||||
|
||||
.clear {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.pull-down {
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
#header {
|
||||
position: relative;
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 106px;
|
||||
height: 102px;
|
||||
}
|
||||
|
||||
#header-content {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
#footer {
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
width: 99%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
%body
|
||||
.container
|
||||
#header.row
|
||||
.col-sm-6.left
|
||||
#header-content
|
||||
%h1
|
||||
= @domain.name
|
||||
.col-sm-6.right
|
||||
%img{src: "#{Rails.root}/public/eis-logo-black-et.png"}
|
||||
.clear
|
||||
%hr
|
||||
.row
|
||||
.col-md-6
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
%h3.panel-title
|
||||
= t(:general)
|
||||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
%dt= t(:name)
|
||||
%dd= @domain.name
|
||||
%dt= Domain.human_attribute_name :registered_at
|
||||
%dd= l(@domain.registered_at)
|
||||
%dt= t(:registrar_name)
|
||||
%dd= @domain.registrar
|
||||
%dt= Domain.human_attribute_name :transfer_code
|
||||
%dd= @domain.transfer_code
|
||||
%dt= t(:valid_to)
|
||||
%dd= l(@domain.valid_to)
|
||||
%dt= t('.outzone_time')
|
||||
%dd= l(@domain.outzone_at)
|
||||
%dt= Domain.human_attribute_name :delete_date
|
||||
%dd= l @domain.delete_date
|
||||
%dt= Domain.human_attribute_name :force_delete_date
|
||||
%dd= l @domain.force_delete_date
|
||||
%dt= t('.locked_by_registrant_at')
|
||||
%dd= l(@domain.locked_by_registrant_at)
|
||||
.col-md-6
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
%h3.panel-title= t('activerecord.models.registrant')
|
||||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
%dt.left_25= t(:name)
|
||||
%dd.left_25= @domain.registrant
|
||||
|
||||
%dt.left_25= t(:id)
|
||||
%dd.left_25= @domain.registrant.code
|
||||
|
||||
%dt.left_25= t(:identity_code)
|
||||
%dd.left_25= @domain.registrant.ident
|
||||
|
||||
%dt.left_25= t(:email)
|
||||
%dd.left_25= @domain.registrant.email
|
||||
|
||||
%dt.left_25= t(:phone)
|
||||
%dd.left_25= @domain.registrant.phone
|
||||
.row
|
||||
.col-md-12
|
||||
- tech_contacts_invalid = @domain.errors.include?(:tech_contacts)
|
||||
- panel_class = tech_contacts_invalid ? 'panel-danger' : 'panel-default'
|
||||
.panel{class: panel_class}
|
||||
.panel-heading.clearfix
|
||||
= t(:tech_contacts)
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-4'}= t(:name)
|
||||
%th{class: 'col-xs-4'}= t(:id)
|
||||
%th{class: 'col-xs-4'}= t(:email)
|
||||
%tbody
|
||||
- @domain.tech_contacts.each do |tc|
|
||||
%tr
|
||||
%td= tc
|
||||
%td= tc.code
|
||||
%td= tc.email
|
||||
- if tech_contacts_invalid
|
||||
%tfoot
|
||||
- @domain.errors.messages[:tech_contacts].each do |x|
|
||||
%tr
|
||||
%td{colspan: 4}= x
|
||||
.row
|
||||
.col-md-12
|
||||
- admin_contacts_invalid = @domain.errors.include?(:admin_contacts)
|
||||
- panel_class = admin_contacts_invalid ? 'panel-danger' : 'panel-default'
|
||||
.panel{class: panel_class}
|
||||
.panel-heading.clearfix
|
||||
= t(:admin_contacts)
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-4'}= t(:name)
|
||||
%th{class: 'col-xs-4'}= t(:id)
|
||||
%th{class: 'col-xs-4'}= t(:email)
|
||||
%tbody
|
||||
- @domain.admin_contacts.each do |ac|
|
||||
%tr
|
||||
%td= ac
|
||||
%td= ac.code
|
||||
%td= ac.email
|
||||
- if admin_contacts_invalid
|
||||
%tfoot
|
||||
- @domain.errors.messages[:admin_contacts].each do |x|
|
||||
%tr
|
||||
%td{colspan: 4}= x
|
||||
.row
|
||||
.col-md-12
|
||||
#domain_statuses.panel.panel-default
|
||||
.panel-heading.clearfix
|
||||
= t(:statuses)
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-6'}= t(:status)
|
||||
%th{class: 'col-xs-6'}= t(:notes)
|
||||
%tbody
|
||||
- @domain.statuses.each do |status|
|
||||
%tr
|
||||
%td
|
||||
- if @domain.pending_json.present? && [DomainStatus::PENDING_UPDATE, DomainStatus::PENDING_DELETE].include?(status)
|
||||
= link_to status, admin_domain_domain_versions_path(@domain.id)
|
||||
- else
|
||||
= status
|
||||
%td= @domain.status_notes[status]
|
||||
.row
|
||||
.col-md-12
|
||||
.panel.panel-default
|
||||
.panel-heading.clearfix
|
||||
= t(:nameservers)
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-4'}= t(:hostname)
|
||||
%th{class: 'col-xs-4'}= t(:ipv4)
|
||||
%th{class: 'col-xs-4'}= t(:ipv6)
|
||||
%tbody
|
||||
- @domain.nameservers.each do |x|
|
||||
%tr
|
||||
%td= x
|
||||
%td= x.ipv4
|
||||
%td= x.ipv6
|
||||
.row
|
||||
.col-md-12
|
||||
.panel.panel-default
|
||||
.panel-heading.clearfix
|
||||
= t(:dnskeys)
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-1'}= t(:flag)
|
||||
%th{class: 'col-xs-1'}= t(:protocol)
|
||||
%th{class: 'col-xs-1'}= t(:algorithm)
|
||||
%th{class: 'col-xs-9'}= t(:public_key)
|
||||
%tbody
|
||||
- @domain.dnskeys.each do |x|
|
||||
%tr
|
||||
%td= x.flags
|
||||
%td= x.protocol
|
||||
%td= x.alg
|
||||
%td= x.public_key
|
||||
.row
|
||||
.col-md-12
|
||||
.panel.panel-default
|
||||
.panel-heading.clearfix
|
||||
= t(:legal_documents)
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-8'}= t(:created_at)
|
||||
%th{class: 'col-xs-4'}= t(:type)
|
||||
%tbody
|
||||
- @domain.legal_documents.each do |x|
|
||||
%tr
|
||||
%td= link_to(x.created_at, [:admin, x])
|
||||
%td= x.document_type
|
|
@ -310,6 +310,7 @@ Rails.application.routes.draw do
|
|||
resource :registry_lock, controller: 'domains/registry_lock', only: :destroy
|
||||
|
||||
member do
|
||||
get :download
|
||||
patch :keep
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue