remove /download from csv file url
This commit is contained in:
parent
a211f542f5
commit
aebf36c356
|
@ -1,6 +1,6 @@
|
|||
class Admin::ExportCsvController < Admin::AdminController
|
||||
|
||||
skip_before_filter :check_xhr, only: [:download]
|
||||
skip_before_filter :check_xhr, only: [:show]
|
||||
|
||||
def export_user_list
|
||||
# export csv file in a background thread
|
||||
|
@ -8,7 +8,8 @@ class Admin::ExportCsvController < Admin::AdminController
|
|||
render json: success_json
|
||||
end
|
||||
|
||||
def download
|
||||
# download
|
||||
def show
|
||||
filename = params.fetch(:id)
|
||||
if export_csv_path = ExportCsv.get_download_path(filename)
|
||||
send_file export_csv_path
|
||||
|
|
|
@ -6,7 +6,7 @@ module Jobs
|
|||
class ExportCsvFile < Jobs::Base
|
||||
CSV_USER_ATTRS = ['id','name','username','email','title','created_at','trust_level','active','admin','moderator','ip_address']
|
||||
CSV_USER_STATS = ['topics_entered','posts_read_count','time_read','topic_count','post_count','likes_given','likes_received']
|
||||
|
||||
|
||||
sidekiq_options retry: false
|
||||
attr_accessor :current_user
|
||||
|
||||
|
@ -108,7 +108,7 @@ module Jobs
|
|||
def notify_user
|
||||
if @current_user
|
||||
if @file_name != "" && File.exists?("#{ExportCsv.base_directory}/#{@file_name}")
|
||||
SystemMessage.create_from_system_user(@current_user, :csv_export_succeeded, download_link: "#{Discourse.base_url}/admin/export_csv/#{@file_name}/download", file_name: @file_name)
|
||||
SystemMessage.create_from_system_user(@current_user, :csv_export_succeeded, download_link: "#{Discourse.base_url}/admin/export_csv/#{@file_name}", file_name: @file_name)
|
||||
else
|
||||
SystemMessage.create_from_system_user(@current_user, :csv_export_failed)
|
||||
end
|
||||
|
|
|
@ -156,12 +156,12 @@ Discourse::Application.routes.draw do
|
|||
end
|
||||
|
||||
resources :export_csv, constraints: AdminConstraint.new do
|
||||
member do
|
||||
get "download" => "export_csv#download", constraints: { id: /[^\/]+/ }
|
||||
end
|
||||
collection do
|
||||
get "users" => "export_csv#export_user_list"
|
||||
end
|
||||
member do
|
||||
get "" => "export_csv#show", constraints: { id: /[^\/]+/ }
|
||||
end
|
||||
end
|
||||
|
||||
resources :badges, constraints: AdminConstraint.new do
|
||||
|
|
|
@ -19,12 +19,12 @@ describe Admin::ExportCsvController do
|
|||
export = ExportCsv.new()
|
||||
ExportCsv.expects(:get_download_path).with(export_filename).returns(export)
|
||||
subject.expects(:send_file).with(export)
|
||||
get :download, id: export_filename
|
||||
get :show, id: export_filename
|
||||
end
|
||||
|
||||
it "returns 404 when the export file does not exist" do
|
||||
ExportCsv.expects(:get_download_path).returns(nil)
|
||||
get :download, id: export_filename
|
||||
get :show, id: export_filename
|
||||
response.should be_not_found
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue