This repository has been archived on 2025-05-04. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
discourse/app/controllers/admin/export_csv_controller.rb

23 lines
543 B
Ruby
Raw Normal View History

2014-08-09 15:58:57 +05:30
class Admin::ExportCsvController < Admin::AdminController
2014-11-19 22:39:23 +05:30
skip_before_filter :check_xhr, only: [:show]
2014-08-09 15:58:57 +05:30
2014-12-07 09:45:22 +05:30
def export_entity
params.require(:entity)
2014-08-09 15:58:57 +05:30
# export csv file in a background thread
2014-12-07 09:45:22 +05:30
Jobs.enqueue(:export_csv_file, entity: params[:entity], user_id: current_user.id)
render json: success_json
end
2014-11-19 22:39:23 +05:30
# download
def show
2014-08-09 15:58:57 +05:30
filename = params.fetch(:id)
if export_csv_path = ExportCsv.get_download_path(filename)
send_file export_csv_path
else
render nothing: true, status: 404
end
end
end