Fix recruitment export: rename view to partial, initialize @module_app in Thread, use binary file mode
This commit is contained in:
parent
1df9e31a78
commit
5f925e402f
|
|
@ -123,14 +123,15 @@ class Admin::RecruitmentController < OrbitAdminController
|
|||
if update_flag
|
||||
Thread.new do
|
||||
begin
|
||||
@module_app = ModuleApp.where(:key => 'recruitment_mod').first
|
||||
@recruitment = Recruitment.where(:category_id.ne=>nil).desc(:created_at)
|
||||
last_updated = Recruitment.max(:updated_at).to_i
|
||||
filename = "public/recruitment_export_#{last_updated}.xlsx"
|
||||
if File.exist?(filename)
|
||||
@thread.update(:status=>{:status=>'finish','finish_percent'=>100,'info'=>I18n.t('recruitment.read_from_cache')})
|
||||
else
|
||||
excel_contents = render_to_string( handlers: [:axlsx], formats: [:xlsx] , layout: false, template: 'admin/recruitment/export_excel.xlsx', locals: {:@recruitment=>@recruitment,:@thread=>@thread} )
|
||||
File.open(filename, 'w') do |f|
|
||||
excel_contents = render_to_string( handlers: [:axlsx], formats: [:xlsx] , partial: 'export_excel.xlsx' )
|
||||
File.open(filename, 'wb') do |f|
|
||||
f.write excel_contents
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue