Class: NdlStatisticsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- NdlStatisticsController
- Defined in:
- app/controllers/ndl_statistics_controller.rb
Instance Method Summary collapse
-
#check_role ⇒ Object
check role.
-
#get_ndl_report ⇒ Object
get_ndl_report.
- #index ⇒ Object
Instance Method Details
#check_role ⇒ Object
check role
15 16 17 18 19 |
# File 'app/controllers/ndl_statistics_controller.rb', line 15 def check_role unless current_user.try(:has_role?, 'Librarian') access_denied; return end end |
#get_ndl_report ⇒ Object
get_ndl_report
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/ndl_statistics_controller.rb', line 22 def get_ndl_report term = params[:term].strip term_name = "平成#{term}年度" unless Term.where(:display_name => term_name).exists? flash[:message] = t('ndl_report.invalid_term') @term = term render :index return false else term_id = Term.where(:display_name => term_name).first.id end unless NdlStatistic.where(:term_id => term_id).exists? flash[:message] = t('ndl_report.term_not_found') @term = term render :index return false else ndl_statistic = NdlStatistic.where(:term_id => term_id).first file = NdlStatistic.get_ndl_report_excelx(ndl_statistic) send_file file, :filename => "#{term}_#{t('ndl_report.filename_excelx')}".encode("cp932"), :type => 'application/x-msexcel', :disposition => 'attachment' end end |
#index ⇒ Object
6 7 8 9 10 11 12 |
# File 'app/controllers/ndl_statistics_controller.rb', line 6 def index current_term = Term.current_term.display_name.gsub(/平成(\d+)年度/,'\1').to_i @term = current_term unless params[:term] respond_to do |format| format.html # index.html.erb end end |