mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 06:26:15 +02:00
Refactor admin/contact_version
and admin/domain_version
csv generation logic
This commit is contained in:
parent
807419bc3a
commit
9fb4a6d7e6
19 changed files with 117 additions and 156 deletions
|
@ -1,13 +1,9 @@
|
|||
module Admin
|
||||
class ContactVersionsController < BaseController
|
||||
include ApplicationHelper
|
||||
include ObjectVersionsHelper
|
||||
|
||||
load_and_authorize_resource class: Version::ContactVersion
|
||||
|
||||
MODEL = Contact
|
||||
CSV_HEADER = ['Name', 'ID', 'Ident', 'Registrar', 'Action', 'Created at'].freeze
|
||||
|
||||
def index
|
||||
params[:q] ||= {}
|
||||
|
||||
|
@ -71,17 +67,5 @@ module Admin
|
|||
|
||||
params_copy
|
||||
end
|
||||
|
||||
def render_by_format(page, filename)
|
||||
respond_to do |format|
|
||||
format.html { render page }
|
||||
format.csv do
|
||||
raw_csv = csv_generate(MODEL, CSV_HEADER, @q.result)
|
||||
send_data raw_csv,
|
||||
filename: "#{filename}_#{Time.zone.now.to_formatted_s(:number)}.csv",
|
||||
type: "#{Mime[:csv]}; charset=utf-8"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue