From 0c4b2c5ebd102df5173b075d32a05912aa816fd0 Mon Sep 17 00:00:00 2001 From: BOHUNG Date: Mon, 2 Mar 2020 15:03:41 +0800 Subject: [PATCH] fix bugs in version 1. --- .../admin/olympiamanagements_controller.rb | 1 + .../olympiamanagements/_school_export.xlsx.axlsx | 11 ++++++++++- app/views/olympiamanagements/_image_form.html.erb | 2 -- .../print_registration_form.html.erb | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/olympiamanagements_controller.rb b/app/controllers/admin/olympiamanagements_controller.rb index b998d56..c3cea92 100644 --- a/app/controllers/admin/olympiamanagements_controller.rb +++ b/app/controllers/admin/olympiamanagements_controller.rb @@ -338,6 +338,7 @@ class Admin::OlympiamanagementsController < OrbitAdminController @value = field[field_name] rescue "" @index = @field_infos.map{|hash| hash.keys[0]}.index(field_name) rescue nil if !@index.nil? + @value = @field_infos.map{|hash| hash.values[0]}[@index]['choices'].index(@value) if @field_infos.map{|hash| hash.values[0]}[@index]['type'] == 'radio' if !['String','Year','select_num','File'].include?(@field_infos.map{|hash| hash.values[0]}[@index]['type']) @value = (@field_infos.map{|hash| hash.values[0]}[@index]['values'][I18n.locale.to_s][@value.to_i].to_s rescue @value) end diff --git a/app/views/admin/olympiamanagements/_school_export.xlsx.axlsx b/app/views/admin/olympiamanagements/_school_export.xlsx.axlsx index 0aa8461..d67996f 100644 --- a/app/views/admin/olympiamanagements/_school_export.xlsx.axlsx +++ b/app/views/admin/olympiamanagements/_school_export.xlsx.axlsx @@ -14,7 +14,16 @@ wb.add_worksheet(name: "school_class") do |sheet| @OlympiaSchoolDataFields.each do |school_data_field| temp_row = [] @fields.each do |field_key| - temp_row << (school_data_field[field_key].to_s rescue '') + if field_key == "enrollment_limited" + if school_data_field.enrollment_limited.to_i == 0 + enrollment_limited = ClassSettingFields.all.select{|class_setting_field| class_setting_field.class_number_range[0] <= school_data_field.class_number && class_setting_field.class_number_range[1] >= school_data_field.class_number}.first.enrollment_available.to_s rescue ClassSettingFields.all.desc(:enrollment_available).first.enrollment_available.to_s + else + enrollment_limited = school_data_field.enrollment_limited + end + temp_row << enrollment_limited + else + temp_row << (school_data_field[field_key].to_s rescue '') + end end export_data_rows << temp_row end diff --git a/app/views/olympiamanagements/_image_form.html.erb b/app/views/olympiamanagements/_image_form.html.erb index 5ec1217..f0ea441 100644 --- a/app/views/olympiamanagements/_image_form.html.erb +++ b/app/views/olympiamanagements/_image_form.html.erb @@ -17,8 +17,6 @@ <% end %> <% end %> - <%= f.check_box(:remove_image,{:checked=>false},"true","false") %> - <%= t(:remove) %> <%= (I18n.locale.to_s == 'en') ? ' this image' : '該圖片' %> <%else%> <%= f.fields_for image_field_name do |index| %> diff --git a/app/views/olympiamanagements/print_registration_form.html.erb b/app/views/olympiamanagements/print_registration_form.html.erb index d4800d2..6dfcd25 100644 --- a/app/views/olympiamanagements/print_registration_form.html.erb +++ b/app/views/olympiamanagements/print_registration_form.html.erb @@ -17,7 +17,7 @@ <% if record_item == "enrollment_limited"%> <% @olympia_school_data_field = OlympiaSchoolDataFields.find(@olympia_school_data_fields_id)%> <% if(@olympia_school_data_field.enrollment_limited.to_i == 0) %> - <%= ClassSettingFields.all.select{|class_setting_field| class_setting_field.class_number_range[0] <= @olympia_school_data_field.class_number && class_setting_field.class_number_range[1] >= @olympia_school_data_field.class_number}.first.enrollment_available.to_s %> + <%= ClassSettingFields.all.select{|class_setting_field| class_setting_field.class_number_range[0] <= @olympia_school_data_field.class_number && class_setting_field.class_number_range[1] >= @olympia_school_data_field.class_number}.first.enrollment_available.to_s rescue ClassSettingFields.all.desc(:enrollment_available).first.enrollment_available.to_s %> <% else %> <%= @olympia_school_data_field.enrollment_limited %> <% end %>