fix bugs in version 1

This commit is contained in:
BOHUNG 2020-02-28 10:26:14 +08:00
parent 52c2e92da2
commit e121a48aa7
5 changed files with 10 additions and 8 deletions

View File

@ -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

View File

@ -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: ''

View File

@ -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

View File

@ -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 %>
<td><%= @value %></td>

View File

@ -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 %>
<td><%= @value %></td>