Class: Marty::ReportController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Marty::ReportController
- Defined in:
- app/controllers/marty/report_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
#failed_authentication, #find_current_user, #get_conf, #handle_unverified_request, #logout_user, #password_authentication, #reset_signed_cookies, #session_expiration, #session_expired?, #set_signed_cookies, #set_user, #start_user_session, #successful_authentication, #toggle_dark_mode, #try_to_autologin, #user_setup
Instance Method Details
#index ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/marty/report_controller.rb', line 2 def index format, req_disposition, title = params[:format], params[:disposition], params[:reptitle] raise 'bad format' unless Marty::ContentHandler::GEN_FORMATS.member?(format) data = Marty::ReportForm.run_eval(params) # hacky: shouldn't have error parsing logic here format = 'json' if data.is_a?(Hash) && (data[:error] || data['error']) # hack for testing -- txt -> csv exp_format = format == 'txt' ? 'csv' : format res, type, disposition, filename = Marty::ContentHandler. export(data, exp_format, title) # hack for testing -- set content-type type = 'text/plain' if format == 'txt' && type =~ /csv/ send_data(res, type: type, filename: filename, disposition: req_disposition || disposition, ) end |