31 lines
672 B
Ruby
31 lines
672 B
Ruby
|
|
class GraphicReportsController < ApplicationController
|
||
|
|
def show
|
||
|
|
report = build_report(params[:type])
|
||
|
|
respond_to do |format|
|
||
|
|
format.xlsx { send_data(report.to_xls, download_attributes_xls(report)) }
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
private
|
||
|
|
|
||
|
|
def video
|
||
|
|
authorize policy_scope(Video).find(params[:video_id])
|
||
|
|
end
|
||
|
|
|
||
|
|
def build_report(type)
|
||
|
|
case type
|
||
|
|
when "nat_geo"
|
||
|
|
authorize ExcelReports::GraphicReports::NatGeoTextGraphicsLog.new(video)
|
||
|
|
else
|
||
|
|
authorize ExcelReports::GraphicReports::DiscoveryGfxCueList.new(video)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
def download_attributes_xls(report)
|
||
|
|
{
|
||
|
|
filename: report.filename,
|
||
|
|
type: Mime[:xlsx]
|
||
|
|
}
|
||
|
|
end
|
||
|
|
end
|