Initial commit
This commit is contained in:
34
app/controllers/audio_reports_controller.rb
Normal file
34
app/controllers/audio_reports_controller.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
class AudioReportsController < 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 "big"
|
||||
authorize ExcelReports::AudioReports::BrayInnovationGroupMusicCueReport.new(video)
|
||||
when "nat_geo"
|
||||
authorize ExcelReports::AudioReports::NatGeoMusicCueSheet.new(video)
|
||||
when "nat_geo-original"
|
||||
authorize ExcelReports::AudioReports::NatGeoOriginalMusicLog.new(video)
|
||||
else
|
||||
authorize ExcelReports::AudioReports::DiscoveryMusicCueReport.new(video)
|
||||
end
|
||||
end
|
||||
|
||||
def download_attributes_xls(report)
|
||||
{
|
||||
filename: report.filename,
|
||||
type: Mime[:xlsx]
|
||||
}
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user