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 if @id_error_msg.length != 0
@error_msg << I18n.t('olympiamanagement.id_number_error') @error_msg << I18n.t('olympiamanagement.id_number_error')
end end
if (@student_params['StudentIdentity'] == '1' || @student_params['StudentIdentity'] == '2') && (@student_params['olympia_student_images']['0']['student_file'].nil? 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 (@olympia_student_data.olympia_student_images.empty? || !@olympia_student_data.olympia_student_images.first.student_file.file.present? 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') @error_msg << I18n.t('olympiamanagement.StudentFile')
end end
end end

View File

@ -47,13 +47,13 @@ class SignUpSetting
@sign_up_setting = SignUpSetting.where(:id.ne=>record.id).last @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 = OlympiaSchoolDataFields.where(:sign_up_setting_id=>@sign_up_setting.id).take_while{true}
@schools.each do |school| @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
end end
def change_all_password def change_all_password
if self.set_default_password && !self.default_password.blank? if self.set_default_password && !self.default_password.blank?
OlympiaSchoolDataFields.where(:sign_up_setting_id=>self.id).each do |school_field| OlympiaSchoolDataFields.where(:sign_up_setting_id=>self.id).each do |school_field|
school_field.password = self.default_password school_field.password = ""
school_field.save school_field.save
end end
self.set_default_password = false self.set_default_password = false

View File

@ -30,6 +30,7 @@
<% @value = field[th_name] %> <% @value = field[th_name] %>
<% @index = @field_infos.map{|hash| hash.keys[0]}.index(th_name) rescue nil%> <% @index = @field_infos.map{|hash| hash.keys[0]}.index(th_name) rescue nil%>
<% if !@index.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))%> <% (['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 %> <% end %>
<td><%= @value %></td> <td><%= @value %></td>

View File

@ -50,6 +50,7 @@
<% @value = field[th_name] %> <% @value = field[th_name] %>
<% @index = @field_infos.map{|hash| hash.keys[0]}.index(th_name) rescue nil%> <% @index = @field_infos.map{|hash| hash.keys[0]}.index(th_name) rescue nil%>
<% if !@index.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))%> <% (['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 %> <% end %>
<td><%= @value %></td> <td><%= @value %></td>