Module: Sinatra::ReportHandler
- Extended by:
- Hexacta
- Defined in:
- lib/sinatra/handlers/reports.rb
Constant Summary
Constants included from Hexacta
Instance Method Summary collapse
Methods included from Hexacta
copy_all_files, copy_dir_structure, copy_file, gem_path, setup_dir
Instance Method Details
#enable_reports ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sinatra/handlers/reports.rb', line 6 def enable_reports p "Enabling reports..." before '/reports/*' do error(403) if authenticated(User)..empty? end get '/reports' do slim :reports end get '/reports/:report_name' do |report_name| date = Date.parse(params[:date]) unless params[:date].nil? date ||= Date.today headers "Content-Disposition" => "attachment;filename=#{report_name}.#{date}.xls", "Content-Type" => "application/octet-stream" slim "reports/#{report_name}".to_sym, locals: { :date => date }, :layout => false end end |