mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 05:05:45 +02:00
Merge pull request #1360 from internetee/improve-domain-and-contact-list-download
Improve domain and contact list download
This commit is contained in:
commit
526369ffbe
21 changed files with 408 additions and 270 deletions
|
@ -4,11 +4,29 @@ class Registrant::DomainsController < RegistrantController
|
||||||
|
|
||||||
params[:q] ||= {}
|
params[:q] ||= {}
|
||||||
normalize_search_parameters do
|
normalize_search_parameters do
|
||||||
@q = current_user_domains.search(params[:q])
|
@q = current_user_domains.search(search_params)
|
||||||
@domains = @q.result.page(params[:page])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
domains = @q.result
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html do
|
||||||
|
@domains = domains.page(params[:page])
|
||||||
|
domains_per_page = params[:results_per_page].to_i
|
||||||
|
@domains = @domains.per(domains_per_page) if domains_per_page.positive?
|
||||||
|
end
|
||||||
|
format.csv do
|
||||||
|
raw_csv = @q.result.to_csv
|
||||||
|
send_data raw_csv, filename: 'domains.csv', type: "#{Mime[:csv]}; charset=utf-8"
|
||||||
|
end
|
||||||
|
format.pdf do
|
||||||
|
view = ActionView::Base.new(ActionController::Base.view_paths, domains: domains)
|
||||||
|
raw_html = view.render(file: 'registrant/domains/list_pdf', layout: false)
|
||||||
|
raw_pdf = domains.pdf(raw_html)
|
||||||
|
|
||||||
|
send_data raw_pdf, filename: 'domains.pdf'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@ -32,23 +50,6 @@ class Registrant::DomainsController < RegistrantController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def download_list
|
|
||||||
authorize! :view, :registrant_domains
|
|
||||||
params[:q] ||= {}
|
|
||||||
normalize_search_parameters do
|
|
||||||
@q = current_user_domains.search(params[:q])
|
|
||||||
@domains = @q
|
|
||||||
end
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.csv { render text: @domains.result.to_csv }
|
|
||||||
format.pdf do
|
|
||||||
pdf = @domains.result.pdf(render_to_string('registrant/domains/download_list', layout: false))
|
|
||||||
send_data pdf, filename: 'domains.pdf'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def normalize_search_parameters
|
def normalize_search_parameters
|
||||||
|
@ -70,4 +71,9 @@ class Registrant::DomainsController < RegistrantController
|
||||||
registrant_domain_delete_confirm_url(token: domain.registrant_verification_token)
|
registrant_domain_delete_confirm_url(token: domain.registrant_verification_token)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def search_params
|
||||||
|
params.require(:q).permit(:name_matches, :registrant_ident_eq, :valid_to_gteq, :valid_to_lteq,
|
||||||
|
:results_per_page)
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -30,37 +30,29 @@ class Registrar
|
||||||
|
|
||||||
normalize_search_parameters do
|
normalize_search_parameters do
|
||||||
@q = contacts.search(search_params)
|
@q = contacts.search(search_params)
|
||||||
@contacts = @q.result(distinct: :true).page(params[:page])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
contacts = @q.result
|
||||||
end
|
|
||||||
|
|
||||||
def download_list
|
|
||||||
authorize! :view, Depp::Contact
|
|
||||||
|
|
||||||
params[:q] ||= {}
|
|
||||||
params[:q].delete_if { |_k, v| v.blank? }
|
|
||||||
if params[:q].length == 1 && params[:q][:name_matches].present?
|
|
||||||
@contacts = Contact.find_by(name: params[:q][:name_matches])
|
|
||||||
end
|
|
||||||
|
|
||||||
contacts = current_registrar_user.registrar.contacts.includes(:registrar)
|
|
||||||
contacts = contacts.filter_by_states(params[:statuses_contains]) if params[:statuses_contains]
|
|
||||||
|
|
||||||
normalize_search_parameters do
|
|
||||||
@q = contacts.search(params[:q])
|
|
||||||
@contacts = @q.result
|
|
||||||
end
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.csv { render text: @contacts.to_csv }
|
format.html do
|
||||||
|
contacts_per_page = params[:results_per_page].to_i
|
||||||
|
@contacts = contacts.page(params[:page])
|
||||||
|
@contacts = @contacts.per(contacts_per_page) if contacts_per_page.positive?
|
||||||
|
end
|
||||||
|
format.csv do
|
||||||
|
raw_csv = contacts.to_csv
|
||||||
|
send_data raw_csv, filename: 'contacts.csv', type: "#{Mime[:csv]}; charset=utf-8"
|
||||||
|
end
|
||||||
format.pdf do
|
format.pdf do
|
||||||
pdf = @contacts.pdf(render_to_string('registrar/contacts/download_list', layout: false))
|
view = ActionView::Base.new(ActionController::Base.view_paths, contacts: contacts)
|
||||||
send_data pdf, filename: 'contacts.pdf'
|
view.class_eval { include ::ApplicationHelper }
|
||||||
|
raw_html = view.render(file: 'registrar/contacts/list_pdf', layout: false)
|
||||||
|
raw_pdf = contacts.pdf(raw_html)
|
||||||
|
|
||||||
|
send_data raw_pdf, filename: 'contacts.pdf'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|
|
@ -47,9 +47,10 @@ class Registrar
|
||||||
domain_presenters << ::DomainPresenter.new(domain: domain, view: view_context)
|
domain_presenters << ::DomainPresenter.new(domain: domain, view: view_context)
|
||||||
end
|
end
|
||||||
|
|
||||||
csv = Registrar::DomainListCSVPresenter.new(domains: domain_presenters, view: view_context).to_s
|
raw_csv = Registrar::DomainListCSVPresenter.new(domains: domain_presenters,
|
||||||
|
view: view_context).to_s
|
||||||
filename = "Domains_#{l(Time.zone.now, format: :filename)}.csv"
|
filename = "Domains_#{l(Time.zone.now, format: :filename)}.csv"
|
||||||
send_data(csv, filename: filename)
|
send_data raw_csv, filename: filename, type: "#{Mime[:csv]}; charset=utf-8"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
!!!
|
|
||||||
%html
|
|
||||||
%head
|
|
||||||
%meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
|
|
||||||
%title Contacts
|
|
||||||
%body
|
|
||||||
.col-md-12
|
|
||||||
.table-responsive
|
|
||||||
%table.table.table-hover.table-bordered.table-condensed
|
|
||||||
%thead
|
|
||||||
%tr
|
|
||||||
%th{class: 'col-xs-2'}
|
|
||||||
=t(:name)
|
|
||||||
%th{class: 'col-xs-2'}
|
|
||||||
=t('.registrant')
|
|
||||||
%th{class: 'col-xs-2'}
|
|
||||||
=t(:valid_to)
|
|
||||||
%th{class: 'col-xs-2'}
|
|
||||||
=t(:registrar_name)
|
|
||||||
%tbody
|
|
||||||
- @domains.result.each do |x|
|
|
||||||
%tr
|
|
||||||
%td= x.name
|
|
||||||
%td= x.registrant
|
|
||||||
%td= l(x.valid_to, format: :short)
|
|
||||||
%td= x.registrar
|
|
||||||
.row
|
|
||||||
.col-md-6
|
|
|
@ -18,6 +18,13 @@
|
||||||
<%= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) %>
|
<%= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<%= label_tag t(:results_per_page) %>
|
||||||
|
<%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
|
@ -32,43 +39,27 @@
|
||||||
<%= f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_until) %>
|
<%= f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_until) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
</div>
|
||||||
<div class="form-group">
|
|
||||||
<%= label_tag t(:results_per_page) %>
|
|
||||||
<%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-3 actions">
|
<div class="row">
|
||||||
<button class="btn btn-primary">
|
<div class="col-md-12 text-right">
|
||||||
|
<button class="btn btn-primary search">
|
||||||
|
|
||||||
<span class="glyphicon glyphicon-search"></span>
|
<span class="glyphicon glyphicon-search"></span>
|
||||||
|
|
||||||
</button>
|
</button>
|
||||||
<%= link_to(t('.reset_btn'), registrant_domains_path, class: 'btn btn-default') %>
|
<%= button_tag t('.download_pdf_btn'),
|
||||||
|
formaction: registrant_domains_path(format: :pdf),
|
||||||
|
name: nil,
|
||||||
|
class: 'btn btn-default' %>
|
||||||
|
<%= button_tag t('.download_csv_btn'),
|
||||||
|
formaction: registrant_domains_path(format: :csv),
|
||||||
|
name: nil,
|
||||||
|
class: 'btn btn-default' %>
|
||||||
|
<%= link_to t('.reset_btn'), registrant_domains_path,
|
||||||
|
class: 'btn btn-default' %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-3">
|
|
||||||
<div class="btn-group" role="group">
|
|
||||||
<button aria-expanded="false" aria-haspopup="true" class="btn btn-default dropdown-toggle" data-toggle="dropdown" type="button">
|
|
||||||
Download
|
|
||||||
<span class="caret"></span>
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li>
|
|
||||||
<%= link_to 'PDF', download_list_registrant_domains_path(q: params[:q], format: "pdf") %>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<%= link_to 'CSV', download_list_registrant_domains_path(q: params[:q], format: "csv") %>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3"></div>
|
|
||||||
<div class="col-md-3"></div>
|
|
||||||
<div class="col-md-3"></div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
32
app/views/registrant/domains/list_pdf.html.erb
Normal file
32
app/views/registrant/domains/list_pdf.html.erb
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover table-bordered table-condensed">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="col-xs-2"><%= Domain.human_attribute_name :name %></th>
|
||||||
|
<th class="col-xs-2"><%= Registrant.model_name.human %></th>
|
||||||
|
<th class="col-xs-2"><%= Domain.human_attribute_name :valid_to %></th>
|
||||||
|
<th class="col-xs-2"><%= Registrar.model_name.human %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<% @domains.each do |domain| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= domain.name %></td>
|
||||||
|
<td><%= domain.registrant %></td>
|
||||||
|
<td><%= l(domain.valid_to, format: :short) %></td>
|
||||||
|
<td><%= domain.registrar %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
117
app/views/registrar/contacts/_search_form.html.erb
Normal file
117
app/views/registrar/contacts/_search_form.html.erb
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
<%= search_form_for [:registrar, @q], html: { style: 'margin-bottom: 0;', class: 'js-form', autocomplete: 'off' } do |f| %>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :name %>
|
||||||
|
<%= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label t(:id) %>
|
||||||
|
<%= f.search_field :code_eq, class: 'form-control', placeholder: t(:id) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label t(:ident) %>
|
||||||
|
<%= f.search_field :ident_matches, class: 'form-control', placeholder: t(:ident) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<%= label_tag t(:ident_type) %>
|
||||||
|
<%= select_tag '[q][ident_type_eq]', options_for_select(ident_types, params[:q][:ident_type_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' } %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label t(:email) %>
|
||||||
|
<%= f.search_field :email_matches, class: 'form-control', placeholder: t(:email) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<%= label_tag t(:country) %>
|
||||||
|
<%= select_tag '[q][country_code_eq]', SortedCountry.all_options(params[:q][:country_code_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' } %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<%= label_tag t(:contact_type) %>
|
||||||
|
<%= select_tag '[q][domain_contacts_type_in]', options_for_select([['admin', 'AdminDomainContact'], ['tech', 'TechDomainContact'], ['registrant', 'registrant']], params[:q][:domain_contacts_type_in]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label t(:registrar_name) %>
|
||||||
|
<%= f.select :registrar_id_eq, Registrar.all.map { |x| [x, x.id] }, { include_blank: true }, class: 'form-control selectize', placeholder: t(:choose) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label t(:created_at_from) %>
|
||||||
|
<%= f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control js-datepicker', placeholder: t(:created_at_from) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label t(:created_at_until) %>
|
||||||
|
<%= f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control js-datepicker', placeholder: t(:created_at_until) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label t(:updated_at) %>
|
||||||
|
<%= f.search_field :updated_at_gteq, value: params[:q][:updated_at_gteq], class: 'form-control js-datepicker', placeholder: t(:updated_at) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-5">
|
||||||
|
<div class="form-group">
|
||||||
|
<%= label_tag t(:status) %>
|
||||||
|
<%= select_tag :statuses_contains, options_for_select(Contact::STATUSES, params[:statuses_contains]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-2">
|
||||||
|
<div class="form-group">
|
||||||
|
<%= label_tag t(:results_per_page) %>
|
||||||
|
<%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-5 text-right" style="padding-top: 25px;">
|
||||||
|
<button class="btn btn-primary">
|
||||||
|
|
||||||
|
<span class="glyphicon glyphicon-search"></span>
|
||||||
|
|
||||||
|
</button>
|
||||||
|
<%= button_tag t('.download_pdf_btn'),
|
||||||
|
formaction: registrar_contacts_path(format: :pdf),
|
||||||
|
name: nil,
|
||||||
|
class: 'btn btn-default' %>
|
||||||
|
<%= button_tag t('.download_csv_btn'),
|
||||||
|
formaction: registrar_contacts_path(format: :csv),
|
||||||
|
name: nil,
|
||||||
|
class: 'btn btn-default' %>
|
||||||
|
<%= link_to(t('.reset_btn'), registrar_contacts_path, class: 'btn btn-default') %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
|
@ -1,30 +0,0 @@
|
||||||
!!!
|
|
||||||
%html
|
|
||||||
%head
|
|
||||||
%meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
|
|
||||||
%title Contacts
|
|
||||||
%body
|
|
||||||
.row
|
|
||||||
.col-md-12
|
|
||||||
.table-responsive
|
|
||||||
%table.table.table-hover.table-bordered.table-condensed
|
|
||||||
%thead
|
|
||||||
%tr
|
|
||||||
%th{class: 'col-xs-2'}
|
|
||||||
=t(:name)
|
|
||||||
%th{class: 'col-xs-2'}
|
|
||||||
=t(:id)
|
|
||||||
%th{class: 'col-xs-2'}
|
|
||||||
=t(:ident)
|
|
||||||
%th{class: 'col-xs-2'}
|
|
||||||
=t(:created_at)
|
|
||||||
%th{class: 'col-xs-2'}
|
|
||||||
=t(:registrar_name)
|
|
||||||
%tbody
|
|
||||||
- @contacts.each do |contact|
|
|
||||||
%tr
|
|
||||||
%td= contact
|
|
||||||
%td= contact.code
|
|
||||||
%td= ident_for(contact)
|
|
||||||
%td= l(contact.created_at, format: :short)
|
|
||||||
%td= contact.registrar
|
|
|
@ -1,120 +0,0 @@
|
||||||
- content_for :actions do
|
|
||||||
= link_to(t(:new), new_registrar_contact_path, class: 'btn btn-primary')
|
|
||||||
= render 'shared/title', name: t(:contacts)
|
|
||||||
|
|
||||||
.row
|
|
||||||
.col-md-12
|
|
||||||
= search_form_for [:registrar, @q], html: { style: 'margin-bottom: 0;', class: 'js-form', autocomplete: 'off' } do |f|
|
|
||||||
.row
|
|
||||||
.col-md-3
|
|
||||||
.form-group
|
|
||||||
= f.label :name
|
|
||||||
= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name)
|
|
||||||
.col-md-3
|
|
||||||
.form-group
|
|
||||||
= f.label t(:id)
|
|
||||||
= f.search_field :code_eq, class: 'form-control', placeholder: t(:id)
|
|
||||||
.col-md-3
|
|
||||||
.form-group
|
|
||||||
= f.label t(:ident)
|
|
||||||
= f.search_field :ident_matches, class: 'form-control', placeholder: t(:ident)
|
|
||||||
.col-md-3
|
|
||||||
.form-group
|
|
||||||
= label_tag t(:ident_type)
|
|
||||||
= select_tag '[q][ident_type_eq]', options_for_select(ident_types, params[:q][:ident_type_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' }
|
|
||||||
.row
|
|
||||||
.col-md-3
|
|
||||||
.form-group
|
|
||||||
= f.label t(:email)
|
|
||||||
= f.search_field :email_matches, class: 'form-control', placeholder: t(:email)
|
|
||||||
.col-md-3
|
|
||||||
.form-group
|
|
||||||
= label_tag t(:country)
|
|
||||||
= select_tag '[q][country_code_eq]', SortedCountry.all_options(params[:q][:country_code_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' }
|
|
||||||
.col-md-6
|
|
||||||
.form-group
|
|
||||||
= label_tag t(:contact_type)
|
|
||||||
= select_tag '[q][domain_contacts_type_in]', options_for_select([['admin', 'AdminDomainContact'], ['tech', 'TechDomainContact'], ['registrant', 'registrant']], params[:q][:domain_contacts_type_in]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' }
|
|
||||||
.row
|
|
||||||
.col-md-3
|
|
||||||
.form-group
|
|
||||||
= f.label t(:registrar_name)
|
|
||||||
= f.select :registrar_id_eq, Registrar.all.map { |x| [x, x.id] }, { include_blank: true }, class: 'form-control selectize', placeholder: t(:choose)
|
|
||||||
.col-md-3
|
|
||||||
.form-group
|
|
||||||
= f.label t(:created_at_from)
|
|
||||||
= f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control js-datepicker', placeholder: t(:created_at_from)
|
|
||||||
.col-md-3
|
|
||||||
.form-group
|
|
||||||
= f.label t(:created_at_until)
|
|
||||||
= f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control js-datepicker', placeholder: t(:created_at_until)
|
|
||||||
.col-md-3
|
|
||||||
.form-group
|
|
||||||
= f.label t(:updated_at)
|
|
||||||
= f.search_field :updated_at_gteq, value: params[:q][:updated_at_gteq], class: 'form-control js-datepicker', placeholder: t(:updated_at)
|
|
||||||
.row
|
|
||||||
.col-md-6
|
|
||||||
.form-group
|
|
||||||
= label_tag t(:status)
|
|
||||||
= select_tag :statuses_contains, options_for_select(Contact::STATUSES, params[:statuses_contains]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' }
|
|
||||||
.col-md-3
|
|
||||||
.form-group
|
|
||||||
= label_tag t(:results_per_page)
|
|
||||||
= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page)
|
|
||||||
.col-md-3{style: 'padding-top: 25px;'}
|
|
||||||
%button.btn.btn-primary
|
|
||||||
|
|
||||||
%span.glyphicon.glyphicon-search
|
|
||||||
|
|
||||||
= link_to(t('.reset_btn'), registrar_contacts_path, class: 'btn btn-default')
|
|
||||||
.row
|
|
||||||
.col-md-3
|
|
||||||
.btn-group{:role => "group"}
|
|
||||||
%button.btn.btn-default.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"}
|
|
||||||
Download
|
|
||||||
%span.caret
|
|
||||||
%ul.dropdown-menu
|
|
||||||
%li= link_to 'PDF', download_list_registrar_contacts_path(q: params[:q], format: "pdf")
|
|
||||||
%li= link_to 'CSV', download_list_registrar_contacts_path(q: params[:q], format: "csv")
|
|
||||||
.col-md-3
|
|
||||||
.col-md-3
|
|
||||||
.col-md-3
|
|
||||||
|
|
||||||
%hr
|
|
||||||
.row
|
|
||||||
.col-md-12
|
|
||||||
.table-responsive
|
|
||||||
%table.table.table-hover.table-bordered.table-condensed.contacts
|
|
||||||
%thead
|
|
||||||
%tr
|
|
||||||
%th{class: 'col-xs-2'}
|
|
||||||
= sort_link(@q, 'name', t(:name))
|
|
||||||
%th{class: 'col-xs-2'}
|
|
||||||
= sort_link(@q, 'code', t(:id))
|
|
||||||
%th{class: 'col-xs-2'}
|
|
||||||
= sort_link(@q, 'ident', t(:ident))
|
|
||||||
%th{class: 'col-xs-2'}
|
|
||||||
= sort_link(@q, 'email', t(:created_at))
|
|
||||||
%th{class: 'col-xs-2'}
|
|
||||||
= sort_link(@q, 'registrar_name', t(:registrar_name))
|
|
||||||
%th{class: 'col-xs-2'}= t(:actions)
|
|
||||||
%tbody
|
|
||||||
- @contacts.each do |contact|
|
|
||||||
%tr
|
|
||||||
%td= link_to(contact.name, registrar_contact_path(id: contact.code))
|
|
||||||
%td= contact.code
|
|
||||||
%td= ident_for(contact)
|
|
||||||
%td= l(contact.created_at, format: :short)
|
|
||||||
%td
|
|
||||||
- if contact.registrar
|
|
||||||
= contact.registrar
|
|
||||||
%td
|
|
||||||
= link_to(t(:edit), edit_registrar_contact_path(contact.code), class: 'btn btn-primary btn-xs')
|
|
||||||
= link_to(t(:delete), delete_registrar_contact_path(contact.code), class: 'btn btn-default btn-xs')
|
|
||||||
|
|
||||||
.row
|
|
||||||
.col-md-6
|
|
||||||
= paginate @contacts
|
|
||||||
.col-md-6.text-right
|
|
||||||
.pagination
|
|
||||||
= t(:result_count, count: @contacts.total_count)
|
|
77
app/views/registrar/contacts/index.html.erb
Normal file
77
app/views/registrar/contacts/index.html.erb
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
<% content_for :actions do %>
|
||||||
|
<%= link_to(t(:new), new_registrar_contact_path, class: 'btn btn-primary') %>
|
||||||
|
<% end %>
|
||||||
|
<%= render 'shared/title', name: t(:contacts) %>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<%= render 'search_form' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr/>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover table-bordered table-condensed contacts">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="col-xs-2">
|
||||||
|
<%= sort_link(@q, 'name', t(:name)) %>
|
||||||
|
</th>
|
||||||
|
<th class="col-xs-2">
|
||||||
|
<%= sort_link(@q, 'code', t(:id)) %>
|
||||||
|
</th>
|
||||||
|
<th class="col-xs-2">
|
||||||
|
<%= sort_link(@q, 'ident', t(:ident)) %>
|
||||||
|
</th>
|
||||||
|
<th class="col-xs-2">
|
||||||
|
<%= sort_link(@q, 'email', t(:created_at)) %>
|
||||||
|
</th>
|
||||||
|
<th class="col-xs-2">
|
||||||
|
<%= sort_link(@q, 'registrar_name', t(:registrar_name)) %>
|
||||||
|
</th>
|
||||||
|
<th class="col-xs-2">
|
||||||
|
<%= t(:actions) %>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @contacts.each do |contact| %>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<%= link_to(contact.name, registrar_contact_path(id: contact.code)) %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= contact.code %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= ident_for(contact) %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= l(contact.created_at, format: :short) %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<% if contact.registrar %>
|
||||||
|
<%= contact.registrar %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= link_to(t(:edit), edit_registrar_contact_path(contact.code), class: 'btn btn-primary btn-xs') %>
|
||||||
|
<%= link_to(t(:delete), delete_registrar_contact_path(contact.code), class: 'btn btn-default btn-xs') %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<%= paginate @contacts %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 text-right">
|
||||||
|
<div class="pagination">
|
||||||
|
<%= t(:result_count, count: @contacts.total_count) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
34
app/views/registrar/contacts/list_pdf.html.erb
Normal file
34
app/views/registrar/contacts/list_pdf.html.erb
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover table-bordered table-condensed">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="col-xs-2"><%= Contact.human_attribute_name :name %></th>
|
||||||
|
<th class="col-xs-2"><%= Contact.human_attribute_name :code %></th>
|
||||||
|
<th class="col-xs-2"><%= Contact.human_attribute_name :ident %></th>
|
||||||
|
<th class="col-xs-2"><%= Contact.human_attribute_name :created_at %></th>
|
||||||
|
<th class="col-xs-2"><%= Registrar.model_name.human %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<% @contacts.each do |contact| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= contact %></td>
|
||||||
|
<td><%= contact.code %></td>
|
||||||
|
<td><%= ident_for(contact) %></td>
|
||||||
|
<td><%= l(contact.created_at, format: :short) %></td>
|
||||||
|
<td><%= contact.registrar %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -74,14 +74,14 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-offset-6 col-md-4 text-right">
|
<div class="col-md-10 text-right">
|
||||||
<button class="btn btn-primary search">
|
<button class="btn btn-primary search">
|
||||||
|
|
||||||
<span class="glyphicon glyphicon-search"></span>
|
<span class="glyphicon glyphicon-search"></span>
|
||||||
|
|
||||||
</button>
|
</button>
|
||||||
<%= button_tag t('.download_btn'), class: 'btn btn-primary export-domains-csv-btn',
|
<%= button_tag t('.download_btn'), formaction: registrar_domains_path(format: 'csv'),
|
||||||
formaction: registrar_domains_path(format: 'csv') %>
|
class: 'btn btn-default' %>
|
||||||
<%= link_to t('.reset_btn'), registrar_domains_path, class: 'btn btn-default' %>
|
<%= link_to t('.reset_btn'), registrar_domains_path, class: 'btn btn-default' %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,7 +6,8 @@ PDFKit.configure do |config|
|
||||||
config.wkhtmltopdf = installed
|
config.wkhtmltopdf = installed
|
||||||
config.default_options = {
|
config.default_options = {
|
||||||
page_size: 'A4',
|
page_size: 'A4',
|
||||||
quiet: true
|
quiet: true,
|
||||||
|
encoding: 'utf-8',
|
||||||
# :print_media_type => true
|
# :print_media_type => true
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,11 +4,10 @@ en:
|
||||||
index:
|
index:
|
||||||
header: Domains
|
header: Domains
|
||||||
registrant: Registrant
|
registrant: Registrant
|
||||||
|
download_pdf_btn: Download PDF
|
||||||
|
download_csv_btn: Download CSV
|
||||||
reset_btn: Reset
|
reset_btn: Reset
|
||||||
|
|
||||||
download_list:
|
|
||||||
registrant: Registrant
|
|
||||||
|
|
||||||
partials:
|
partials:
|
||||||
registrant:
|
registrant:
|
||||||
header: Registrant
|
header: Registrant
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
en:
|
en:
|
||||||
registrar:
|
registrar:
|
||||||
contacts:
|
contacts:
|
||||||
index:
|
search_form:
|
||||||
|
download_pdf_btn: Download PDF
|
||||||
|
download_csv_btn: Download CSV
|
||||||
reset_btn: Reset
|
reset_btn: Reset
|
||||||
|
|
||||||
partials:
|
partials:
|
||||||
|
|
|
@ -17,7 +17,7 @@ en:
|
||||||
transfer_btn: Transfer
|
transfer_btn: Transfer
|
||||||
|
|
||||||
search_form:
|
search_form:
|
||||||
download_btn: Download as CSV
|
download_btn: Download CSV
|
||||||
reset_btn: Reset
|
reset_btn: Reset
|
||||||
|
|
||||||
domain:
|
domain:
|
||||||
|
|
|
@ -87,7 +87,6 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
collection do
|
collection do
|
||||||
get 'check'
|
get 'check'
|
||||||
get 'download_list'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -151,11 +150,6 @@ Rails.application.routes.draw do
|
||||||
resources :registrars, only: :show
|
resources :registrars, only: :show
|
||||||
resources :domains, only: %i[index show] do
|
resources :domains, only: %i[index show] do
|
||||||
resources :contacts, only: %i[show edit update]
|
resources :contacts, only: %i[show edit update]
|
||||||
|
|
||||||
collection do
|
|
||||||
get :download_list
|
|
||||||
end
|
|
||||||
|
|
||||||
member do
|
member do
|
||||||
get 'confirmation'
|
get 'confirmation'
|
||||||
end
|
end
|
||||||
|
|
25
test/integration/registrant_area/domains_test.rb
Normal file
25
test/integration/registrant_area/domains_test.rb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class RegistrantAreaDomainsIntegrationTest < ApplicationIntegrationTest
|
||||||
|
setup do
|
||||||
|
sign_in users(:registrant)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_downloads_list_as_csv
|
||||||
|
get registrant_domains_path(format: :csv)
|
||||||
|
|
||||||
|
assert_response :ok
|
||||||
|
assert_equal "#{Mime[:csv]}; charset=utf-8", response.headers['Content-Type']
|
||||||
|
assert_equal 'attachment; filename="domains.csv"', response.headers['Content-Disposition']
|
||||||
|
assert_not_empty response.body
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_downloads_list_as_pdf
|
||||||
|
get registrant_domains_path(format: :pdf)
|
||||||
|
|
||||||
|
assert_response :ok
|
||||||
|
assert_equal Mime[:pdf], response.headers['Content-Type']
|
||||||
|
assert_equal 'attachment; filename="domains.pdf"', response.headers['Content-Disposition']
|
||||||
|
assert_not_empty response.body
|
||||||
|
end
|
||||||
|
end
|
25
test/integration/registrar_area/contacts_test.rb
Normal file
25
test/integration/registrar_area/contacts_test.rb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class RegistrarAreaContactsIntegrationTest < ApplicationIntegrationTest
|
||||||
|
setup do
|
||||||
|
sign_in users(:api_bestnames)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_downloads_list_as_csv
|
||||||
|
get registrar_contacts_path(format: :csv)
|
||||||
|
|
||||||
|
assert_response :ok
|
||||||
|
assert_equal "#{Mime[:csv]}; charset=utf-8", response.headers['Content-Type']
|
||||||
|
assert_equal 'attachment; filename="contacts.csv"', response.headers['Content-Disposition']
|
||||||
|
assert_not_empty response.body
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_downloads_list_as_pdf
|
||||||
|
get registrar_contacts_path(format: :pdf)
|
||||||
|
|
||||||
|
assert_response :ok
|
||||||
|
assert_equal Mime[:pdf], response.headers['Content-Type']
|
||||||
|
assert_equal 'attachment; filename="contacts.pdf"', response.headers['Content-Disposition']
|
||||||
|
assert_not_empty response.body
|
||||||
|
end
|
||||||
|
end
|
20
test/integration/registrar_area/domains_test.rb
Normal file
20
test/integration/registrar_area/domains_test.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class RegistrarAreaDomainsIntegrationTest < ApplicationIntegrationTest
|
||||||
|
setup do
|
||||||
|
sign_in users(:api_bestnames)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_downloads_list_as_csv
|
||||||
|
now = Time.zone.parse('2010-07-05 08:00')
|
||||||
|
travel_to now
|
||||||
|
|
||||||
|
get registrar_domains_path(format: :csv)
|
||||||
|
|
||||||
|
assert_response :ok
|
||||||
|
assert_equal "#{Mime[:csv]}; charset=utf-8", response.headers['Content-Type']
|
||||||
|
assert_equal %(attachment; filename="Domains_#{l(now, format: :filename)}.csv"),
|
||||||
|
response.headers['Content-Disposition']
|
||||||
|
assert_not_empty response.body
|
||||||
|
end
|
||||||
|
end
|
|
@ -14,7 +14,7 @@ class RegistrarDomainsTest < ApplicationSystemTestCase
|
||||||
CSV
|
CSV
|
||||||
|
|
||||||
visit registrar_domains_url
|
visit registrar_domains_url
|
||||||
click_button 'Download as CSV'
|
click_button 'Download CSV'
|
||||||
assert_equal 'attachment; filename="Domains_2010-07-05_10.30.csv"', response_headers['Content-Disposition']
|
assert_equal 'attachment; filename="Domains_2010-07-05_10.30.csv"', response_headers['Content-Disposition']
|
||||||
assert_equal expected_csv, page.body
|
assert_equal expected_csv, page.body
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue