Fix bug.
This commit is contained in:
parent
f4c48ddf72
commit
b7b5a74315
|
@ -180,15 +180,19 @@ class Admin::AnnouncementsController < OrbitAdminController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if update_flag
|
if update_flag
|
||||||
|
@host = Site.first.root_url
|
||||||
|
if @host == "http"
|
||||||
|
@host = request.protocol + request.host_with_port
|
||||||
|
end
|
||||||
Thread.new do
|
Thread.new do
|
||||||
begin
|
begin
|
||||||
@announcements = Bulletin.all.desc(:created_at)
|
@announcements = Bulletin.all.desc(:created_at)
|
||||||
last_updated = Bulletin.max(:updated_at).to_i
|
last_updated = [Bulletin.max(:updated_at).to_i, AnnouncementSetting.max(:updated_at).to_i].max
|
||||||
filename = "public/announcement_export_#{last_updated}.xlsx"
|
filename = "public/announcement_export_#{last_updated}.xlsx"
|
||||||
if File.exist?(filename)
|
if File.exist?(filename)
|
||||||
@thread.update(:status=>{:status=>'finish','finish_percent'=>100,'info'=>I18n.t('announcement.read_from_cache')})
|
@thread.update(:status=>{:status=>'finish','finish_percent'=>100,'info'=>I18n.t('announcement.read_from_cache')})
|
||||||
else
|
else
|
||||||
excel_contents = render_to_string( handlers: [:axlsx], formats: [:xlsx] ,partial: 'export_excel.xlsx',locals: {:@announcements=>@announcements,:@thread=>@thread} )
|
excel_contents = render_to_string( handlers: [:axlsx], formats: [:xlsx] ,partial: 'export_excel.xlsx',locals: {:@announcements=>@announcements,:@thread=>@thread, :@host=>@host} )
|
||||||
File.open(filename, 'w') do |f|
|
File.open(filename, 'w') do |f|
|
||||||
f.write excel_contents
|
f.write excel_contents
|
||||||
end
|
end
|
||||||
|
|
|
@ -143,7 +143,8 @@ wb.add_worksheet(name: "Annoucement") do |sheet|
|
||||||
row << (anns.is_top? ? 1 : 0)
|
row << (anns.is_top? ? 1 : 0)
|
||||||
row << (anns.is_hot? ? 1 : 0)
|
row << (anns.is_hot? ? 1 : 0)
|
||||||
row << (anns.is_hidden? ? 1 : 0)
|
row << (anns.is_hidden? ? 1 : 0)
|
||||||
row << ("http://" + request.host_with_port + anns.image.url rescue "")
|
image_url = anns.image.url rescue ""
|
||||||
|
row << (image_url.blank? ? "" : (@host + image_url))
|
||||||
row << anns.image_description_translations["en"]
|
row << anns.image_description_translations["en"]
|
||||||
row << anns.image_description_translations["zh_tw"]
|
row << anns.image_description_translations["zh_tw"]
|
||||||
row << anns.title_translations["en"]
|
row << anns.title_translations["en"]
|
||||||
|
|
Loading…
Reference in New Issue