From e121a48aa78e0d12bce2843187cca0d227d361f9 Mon Sep 17 00:00:00 2001 From: BOHUNG Date: Fri, 28 Feb 2020 10:26:14 +0800 Subject: [PATCH] fix bugs in version 1 --- app/controllers/olympiamanagements_controller.rb | 4 ++-- app/models/olympia_school_data_fields.rb | 8 ++++---- app/models/sign_up_setting.rb | 4 ++-- .../olympiamanagements/sign_up_student_data_list.html.erb | 1 + .../olympiamanagements/print_registration_form.html.erb | 1 + 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/controllers/olympiamanagements_controller.rb b/app/controllers/olympiamanagements_controller.rb index fcbde15..6fd4ffd 100644 --- a/app/controllers/olympiamanagements_controller.rb +++ b/app/controllers/olympiamanagements_controller.rb @@ -677,8 +677,8 @@ class OlympiamanagementsController < ApplicationController if @id_error_msg.length != 0 @error_msg << I18n.t('olympiamanagement.id_number_error') end - if (@student_params['StudentIdentity'] == '1' || @student_params['StudentIdentity'] == '2') && (@student_params['olympia_student_images']['0']['student_file'].nil? rescue true) - if (@olympia_student_data.olympia_student_images.empty? || !@olympia_student_data.olympia_student_images.first.student_file.file.present? rescue true) + if (@student_params['StudentIdentity'] == '1' || @student_params['StudentIdentity'] == '2') && (@student_params['remove_image']=='true' || (@student_params['olympia_student_images']['0']['student_file'].nil? rescue true)) + if @student_params['remove_image']=='true' || (@olympia_student_data.olympia_student_images.empty? || !@olympia_student_data.olympia_student_images.first.student_file.file.present? rescue true) @error_msg << I18n.t('olympiamanagement.StudentFile') end end diff --git a/app/models/olympia_school_data_fields.rb b/app/models/olympia_school_data_fields.rb index c7cca64..ceadb21 100644 --- a/app/models/olympia_school_data_fields.rb +++ b/app/models/olympia_school_data_fields.rb @@ -5,13 +5,13 @@ class OlympiaSchoolDataFields include OrbitModel::Impression # encoding: utf-8 field :account_number , type: String , default: '' - field :password , type: String , default: '' + field :password , type: String , default: '' field :school_name , type: String , default: '' - field :school_code , type: String , default: '' - field :school_address , type: String , default: '' + field :school_code , type: String , default: '' + field :school_address , type: String , default: '' field :class_number , type: Fixnum , default: 0 field :enrollment_limited , type: Fixnum , default: 0 - field :school_contact_person_name , type: String , default: '' + field :school_contact_person_name , type: String , default: '' field :department_job_title , type: String , default: '' field :office_tel_number , type: String , default: '' field :fax , type: String , default: '' diff --git a/app/models/sign_up_setting.rb b/app/models/sign_up_setting.rb index 75c0da7..934c293 100644 --- a/app/models/sign_up_setting.rb +++ b/app/models/sign_up_setting.rb @@ -47,13 +47,13 @@ class SignUpSetting @sign_up_setting = SignUpSetting.where(:id.ne=>record.id).last @schools = OlympiaSchoolDataFields.where(:sign_up_setting_id=>@sign_up_setting.id).take_while{true} @schools.each do |school| - OlympiaSchoolDataFields.create(school.attributes.except(*['_id','enrollment',"view_count","created_at","updated_at","sign_up_setting_id"]).merge({:sign_up_setting_id => record.id})) + OlympiaSchoolDataFields.create(school.attributes.slice(*["account_number","password","school_name","school_code","school_address","class_number"]).merge({:sign_up_setting_id => record.id})) end end def change_all_password if self.set_default_password && !self.default_password.blank? OlympiaSchoolDataFields.where(:sign_up_setting_id=>self.id).each do |school_field| - school_field.password = self.default_password + school_field.password = "" school_field.save end self.set_default_password = false diff --git a/app/views/admin/olympiamanagements/sign_up_student_data_list.html.erb b/app/views/admin/olympiamanagements/sign_up_student_data_list.html.erb index a590c9f..f6741b9 100644 --- a/app/views/admin/olympiamanagements/sign_up_student_data_list.html.erb +++ b/app/views/admin/olympiamanagements/sign_up_student_data_list.html.erb @@ -30,6 +30,7 @@ <% @value = field[th_name] %> <% @index = @field_infos.map{|hash| hash.keys[0]}.index(th_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' %> <% (['String','Year','select_num','File'].include?(@field_infos.map{|hash| hash.values[0]}[@index]['type'])) ? (nil) : (@value=(@field_infos.map{|hash| hash.values[0]}[@index]['values'][I18n.locale.to_s][@value.to_i].to_s rescue @value))%> <% end %> <%= @value %> diff --git a/app/views/olympiamanagements/print_registration_form.html.erb b/app/views/olympiamanagements/print_registration_form.html.erb index 477509f..d4800d2 100644 --- a/app/views/olympiamanagements/print_registration_form.html.erb +++ b/app/views/olympiamanagements/print_registration_form.html.erb @@ -50,6 +50,7 @@ <% @value = field[th_name] %> <% @index = @field_infos.map{|hash| hash.keys[0]}.index(th_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' %> <% (['String','Year','select_num','File'].include?(@field_infos.map{|hash| hash.values[0]}[@index]['type'])) ? (nil) : (@value=(@field_infos.map{|hash| hash.values[0]}[@index]['values'][I18n.locale.to_s][@value.to_i].to_s rescue @value))%> <% end %> <%= @value %>