mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 06:34:46 +02:00
Merge pull request #1812 from internetee/1775-domain-csv-download-admin
Add button to download filtered domains CSV
This commit is contained in:
commit
3e06b4ecc6
6 changed files with 44 additions and 7 deletions
|
@ -7,6 +7,9 @@ prepare:
|
|||
plugins:
|
||||
brakeman:
|
||||
enabled: true
|
||||
checks:
|
||||
mass_assign_permit!:
|
||||
enabled: false
|
||||
bundler-audit:
|
||||
enabled: true
|
||||
duplication:
|
||||
|
|
|
@ -8,6 +8,8 @@ $(window).load ->
|
|||
|
||||
$('[data-toggle="popover"]').popover()
|
||||
|
||||
$('[data-toggle="tooltip"]').tooltip()
|
||||
|
||||
# doublescroll
|
||||
$('[data-doublescroll]').doubleScroll({
|
||||
onlyIfScroll: false,
|
||||
|
|
|
@ -27,8 +27,17 @@ module Admin
|
|||
params[:q][:name_matches] = n_cache # we don't want to show wildcards in search form
|
||||
end
|
||||
end
|
||||
|
||||
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
@domains
|
||||
end
|
||||
format.csv do
|
||||
raw_csv = @domains.to_csv
|
||||
send_data raw_csv, filename: 'domains.csv', type: "#{Mime[:csv]}; charset=utf-8"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<%= 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="col-md-2">
|
||||
<div class="form-group">
|
||||
<%= f.label :registrant_ident, for: nil %>
|
||||
<%= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) %>
|
||||
|
@ -18,7 +18,7 @@
|
|||
<%= f.search_field :contacts_ident_eq, class: 'form-control', placeholder: t(:contact_ident) %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<%= f.label :nameserver_hostname, for: nil %>
|
||||
<%= f.search_field :nameservers_hostname_eq, class: 'form-control', placeholder: t(:nameserver_hostname) %>
|
||||
|
@ -26,7 +26,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-5">
|
||||
<div class="form-group">
|
||||
<%= f.label :registrar_name, for: nil %>
|
||||
<%= f.select :registrar_id_eq, Registrar.all.map { |x| [x, x.id] }, { include_blank: true }, class: 'form-control selectize' %>
|
||||
|
@ -38,7 +38,7 @@
|
|||
<%= f.search_field :valid_to_gteq, value: params[:q][:valid_to_gteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_from) %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<%= f.label :valid_to_until, for: nil %>
|
||||
<%= f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_until) %>
|
||||
|
@ -46,7 +46,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-5">
|
||||
<div class="form-group">
|
||||
<%= label_tag :status, nil, for: nil %>
|
||||
<%= select_tag :statuses_contains, options_for_select(DomainStatus::STATUSES, params[:statuses_contains]), { multiple: true, class: 'form-control js-combobox' } %>
|
||||
|
@ -58,13 +58,17 @@
|
|||
<%= 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="col-md-4 actions">
|
||||
<button class="btn btn-primary">
|
||||
|
||||
<span class="glyphicon glyphicon-search"></span>
|
||||
|
||||
</button>
|
||||
<%= link_to t('.download_csv_btn'), admin_domains_path(format: :csv, params: params.permit!),
|
||||
"data-toggle" => "tooltip", "data-placement" => "bottom", "title" => t('.download_csv_btn'),
|
||||
class: 'btn btn-default' %>
|
||||
<%= link_to t('.reset_btn'), admin_domains_path, class: 'btn btn-default' %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -11,6 +11,7 @@ en:
|
|||
|
||||
search_form:
|
||||
reset_btn: Reset
|
||||
download_csv_btn: CSV
|
||||
|
||||
form:
|
||||
pending_delete: &pending_delete
|
||||
|
|
18
test/system/admin_area/domains/csv_test.rb
Normal file
18
test/system/admin_area/domains/csv_test.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class AdminAreaCsvTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:admin)
|
||||
end
|
||||
|
||||
def test_downloads_domain_list_as_csv
|
||||
search_params = {"valid_to_lteq"=>nil}
|
||||
expected_csv = Domain.includes(:registrar, :registrant).search(search_params).result.to_csv
|
||||
|
||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||
visit admin_domains_url
|
||||
click_link('CSV')
|
||||
assert_equal "attachment; filename=\"domains.csv\"; filename*=UTF-8''domains.csv", response_headers['Content-Disposition']
|
||||
assert_equal expected_csv, page.body
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue