mirror of
https://github.com/internetee/registry.git
synced 2025-07-27 21:16:12 +02:00
Fix contact history csv
This commit is contained in:
parent
a9b942dac0
commit
578b75da20
3 changed files with 50 additions and 11 deletions
|
@ -1,9 +1,13 @@
|
|||
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] ||= {}
|
||||
|
||||
|
@ -56,5 +60,19 @@ module Admin
|
|||
def create_where_string(key, value)
|
||||
" AND object->>'#{key}' ~* '#{value}'"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def render_by_format(page, filename)
|
||||
respond_to do |format|
|
||||
format.html { render page }
|
||||
format.csv do
|
||||
raw_csv = csv_generate(MODEL, CSV_HEADER)
|
||||
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