Fix export and view
This commit is contained in:
parent
90f7fbedf1
commit
75267a2105
|
|
@ -123,14 +123,15 @@ class Admin::EventNewsController < OrbitAdminController
|
||||||
if update_flag
|
if update_flag
|
||||||
Thread.new do
|
Thread.new do
|
||||||
begin
|
begin
|
||||||
|
@module_app = ModuleApp.where(:key => 'event_news_mod').first
|
||||||
@event_news = EventNews.where(:category_id.ne=>nil).desc(:created_at)
|
@event_news = EventNews.where(:category_id.ne=>nil).desc(:created_at)
|
||||||
last_updated = EventNews.max(:updated_at).to_i
|
last_updated = EventNews.max(:updated_at).to_i
|
||||||
filename = "public/event_news_export_#{last_updated}.xlsx"
|
filename = "public/event_news_export_#{last_updated}.xlsx"
|
||||||
if File.exist?(filename)
|
if File.exist?(filename)
|
||||||
@thread.update(:status=>{:status=>'finish','finish_percent'=>100,'info'=>I18n.t('event_news.read_from_cache')})
|
@thread.update(:status=>{:status=>'finish','finish_percent'=>100,'info'=>I18n.t('event_news.read_from_cache')})
|
||||||
else
|
else
|
||||||
excel_contents = render_to_string( handlers: [:axlsx], formats: [:xlsx] , layout: false, template: 'admin/event_news/export_excel.xlsx', locals: {:@event_news=>@event_news,:@thread=>@thread} )
|
excel_contents = render_to_string( handlers: [:axlsx], formats: [:xlsx] , partial: 'export_excel.xlsx' )
|
||||||
File.open(filename, 'w') do |f|
|
File.open(filename, 'wb') do |f|
|
||||||
f.write excel_contents
|
f.write excel_contents
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -378,7 +378,6 @@
|
||||||
<a id="add_carousel_image" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
|
<a id="add_carousel_image" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Mail Group Module -->
|
<!-- Mail Group Module -->
|
||||||
<div class="tab-pane fade" id="mail-group">
|
<div class="tab-pane fade" id="mail-group">
|
||||||
|
|
@ -428,7 +427,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Language Tabs -->
|
<!-- Language Tabs -->
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue