add SignUpSetting active status
This commit is contained in:
parent
c3c4773bac
commit
8ccddb921a
Binary file not shown.
|
@ -77,7 +77,7 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
||||||
redirect_to :back
|
redirect_to :back
|
||||||
end
|
end
|
||||||
elsif params[:type] == 'sign_up_setting'
|
elsif params[:type] == 'sign_up_setting'
|
||||||
@sign_up_setting = SignUpSetting.find(params[:id]) rescue SignUpSetting.new
|
@sign_up_setting = SignUpSetting.find(params[:id]) rescue SignUpSetting.where(:active=>true).last
|
||||||
if @sign_up_setting.nil?
|
if @sign_up_setting.nil?
|
||||||
render_404_html
|
render_404_html
|
||||||
else
|
else
|
||||||
|
@ -206,7 +206,6 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def sign_up_setting
|
def sign_up_setting
|
||||||
@sign_up_setting = (SignUpSetting.all.length == 0) ? (SignUpSetting.new) : (SignUpSetting.last)
|
|
||||||
@site_locales = Site.first.in_use_locales
|
@site_locales = Site.first.in_use_locales
|
||||||
@site_locales.delete(I18n.locale)
|
@site_locales.delete(I18n.locale)
|
||||||
@site_locales.insert(0,I18n.locale)
|
@site_locales.insert(0,I18n.locale)
|
||||||
|
@ -228,32 +227,59 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
||||||
def sign_up_student_data_list
|
def sign_up_student_data_list
|
||||||
page_num = params[:page] || 1
|
page_num = params[:page] || 1
|
||||||
@field_infos = StudentDataField.first.student_data_fields
|
@field_infos = StudentDataField.first.student_data_fields
|
||||||
@sign_up_setting_id = SignUpSetting.last.id
|
@sign_up_setting_id = SignUpSetting.id
|
||||||
@student_fields = OlympiaStudentDataField.where(:olympia_school_data_fields_id=>params[:olympia_school_id],:sign_up_setting_id=>@sign_up_setting_id).asc(:id).page(page_num).per(10)
|
@student_fields = OlympiaStudentDataField.where(:olympia_school_data_fields_id=>params[:olympia_school_id],:sign_up_setting_id=>@sign_up_setting_id).asc(:id).page(page_num).per(10)
|
||||||
end
|
end
|
||||||
def export_sign_up_student_data
|
def export_sign_up_student_data
|
||||||
# @OlympiaSchoolDataFields = OlympiaSchoolDataFields.all.asc(:id)
|
@student_data_fields = OlympiaStudentDataField.all.asc(:id)
|
||||||
# dir_path = 'tmp/olypiamanagement/'
|
dir_path = 'tmp/olypiamanagement/'
|
||||||
# #FileUtils.rm_r(dir_path, :force => true) if Dir.exist?(dir_path)
|
#FileUtils.rm_r(dir_path, :force => true) if Dir.exist?(dir_path)
|
||||||
# FileUtils.mkdir dir_path if !Dir.exist?(dir_path) #create dir for storing tmp_file if dir doesn't exist
|
FileUtils.mkdir dir_path if !Dir.exist?(dir_path) #create dir for storing tmp_file if dir doesn't exist
|
||||||
# @filename = 'school_export.xlsx'
|
@field_infos = (StudentDataField.first || StudentDataField.new).student_data_fields
|
||||||
# Dir.chdir(dir_path) do
|
@student_data_list = []
|
||||||
# File.open(@filename, 'w') do |f|
|
@fields = [ "school_code", "school_name" , "StudentName" ,"StudentSex","StudentIDNO","birth_date","StudentClass","StudentPhone","StudentCode","StudentAddress","StudentArea","StudentIdentity"]
|
||||||
# f.write render_to_string( :handlers=> [:axlsx], :formats=> [:xlsx] ,:partial=> 'school_export.xlsx',:locals=> {:@OlympiaSchoolDataFields=>@OlympiaSchoolDataFields} )
|
@student_data_fields.each do |field|
|
||||||
# end
|
@tmp_student_data = []
|
||||||
# end
|
@fields.each do |field_name|
|
||||||
# tmp_filename_data = File.read(dir_path +@filename)
|
@value = field[field_name] rescue ""
|
||||||
# send_data(tmp_filename_data, type: 'application/xlsx', disposition: 'attachment', filename: @filename)
|
@index = @field_infos.map{|hash| hash.keys[0]}.index(field_name) rescue nil
|
||||||
|
if !@index.nil?
|
||||||
|
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
|
||||||
|
else
|
||||||
|
if field_name == 'birth_date'
|
||||||
|
@value = "#{field.StudentBirthYear}-#{field.StudentBirthMonth}-#{field.StudentBirthDay}"
|
||||||
|
else
|
||||||
|
@school = OlympiaSchoolDataFields.find(field.olympia_school_data_fields_id) rescue nil
|
||||||
|
if !@school.nil?
|
||||||
|
@value = @school[field_name].to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@tmp_student_data << @value
|
||||||
|
end
|
||||||
|
@student_data_list << @tmp_student_data
|
||||||
|
end
|
||||||
|
#render :html => @student_data_list and return
|
||||||
|
@filename = 'student_export.xlsx'
|
||||||
|
Dir.chdir(dir_path) do
|
||||||
|
File.open(@filename, 'w') do |f|
|
||||||
|
f.write render_to_string( :handlers=> [:axlsx], :formats=> [:xlsx] ,:partial=> 'student_export.xlsx',:locals=> {:@student_data_list=>@student_data_list,:@fields=>@fields} )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
tmp_filename_data = File.read(dir_path +@filename)
|
||||||
|
send_data(tmp_filename_data, type: 'application/xlsx', disposition: 'attachment', filename: @filename)
|
||||||
end
|
end
|
||||||
def download_scan_file_of_certificate
|
def download_scan_file_of_certificate
|
||||||
@sign_up_setting_id = SignUpSetting.last.id
|
@sign_up_setting_id = @sign_up_setting.id
|
||||||
if !params[:student_id].to_s.blank?
|
if !params[:student_id].to_s.blank?
|
||||||
@student = OlympiaStudentDataField.where(:student_id=>params[:student_id]).first
|
@student = OlympiaStudentDataField.find(params[:student_id]) rescue nil
|
||||||
if @student.nil?
|
if @student.nil?
|
||||||
redirect_to :back
|
redirect_to :back
|
||||||
else
|
else
|
||||||
tmp_filename_data = @student.olympia_student_images.last.student_file.file.read
|
tmp_filename_data = @student.olympia_student_images.last.student_file.file.read
|
||||||
send_data(tmp_filename_data, type: 'image/jpg', disposition: 'attachment', filename: "#{params[:student_name]}.jpg")
|
send_data(tmp_filename_data, type: 'image/jpg', disposition: 'attachment', filename: "#{@student.StudentName}.jpg")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@student_data_list = OlympiaStudentDataField.where(:sign_up_setting_id=>@sign_up_setting_id)
|
@student_data_list = OlympiaStudentDataField.where(:sign_up_setting_id=>@sign_up_setting_id)
|
||||||
|
@ -290,7 +316,7 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def add_sign_up_student_data
|
def add_sign_up_student_data
|
||||||
@olympia_school_data_field = OlympiaSchoolDataFields.where(:account_number=>session[:olympia_login_id]).first
|
@olympia_school_data_field = OlympiaSchoolDataFields.find(params[:school_id]) rescue nil
|
||||||
redirect_to :back if @olympia_school_data_field.nil?
|
redirect_to :back if @olympia_school_data_field.nil?
|
||||||
@required_fields = [:school_contact_person_name,:department_job_title,:office_tel_number,:fax,:mobile_number,:email]
|
@required_fields = [:school_contact_person_name,:department_job_title,:office_tel_number,:fax,:mobile_number,:email]
|
||||||
@flag = true
|
@flag = true
|
||||||
|
@ -339,12 +365,12 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
||||||
if @olympia_student_data.nil?
|
if @olympia_student_data.nil?
|
||||||
@olympia_student_data = OlympiaStudentDataField.create(@student_params)
|
@olympia_student_data = OlympiaStudentDataField.create(@student_params)
|
||||||
@olympia_student_data.olympia_school_data_fields_id = @olympia_school_data_field.id
|
@olympia_student_data.olympia_school_data_fields_id = @olympia_school_data_field.id
|
||||||
@olympia_student_data.sign_up_setting_id = SignUpSetting.last.id
|
@olympia_student_data.sign_up_setting_id = @sign_up_setting.id
|
||||||
@olympia_student_data.save
|
@olympia_student_data.save
|
||||||
else
|
else
|
||||||
@olympia_student_data.update_attributes(@student_params)
|
@olympia_student_data.update_attributes(@student_params)
|
||||||
end
|
end
|
||||||
redirect_to admin_olympiamanagements_sign_up_student_data_list_path
|
redirect_to admin_olympiamanagements_sign_up_student_data_list_path+"?olympia_school_id=#{params[:school_id]}"
|
||||||
else
|
else
|
||||||
render 'import_error_msg'
|
render 'import_error_msg'
|
||||||
end
|
end
|
||||||
|
@ -361,8 +387,9 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
||||||
end
|
end
|
||||||
def create_first_fields
|
def create_first_fields
|
||||||
StudentDataField.create if StudentDataField.all.length == 0
|
StudentDataField.create if StudentDataField.all.length == 0
|
||||||
SchoolDataFields.create if StudentDataField.all.length == 0
|
SchoolDataFields.create if SchoolDataFields.all.length == 0
|
||||||
SignUpSetting.create if SignUpSetting.all.length == 0
|
SignUpSetting.create if SignUpSetting.all.length == 0
|
||||||
|
@sign_up_setting = SignUpSetting.where(:active=>true).last
|
||||||
end
|
end
|
||||||
def download_import_file
|
def download_import_file
|
||||||
@OlympiaSchoolDataFields = OlympiaSchoolDataFields.all.asc(:id)
|
@OlympiaSchoolDataFields = OlympiaSchoolDataFields.all.asc(:id)
|
||||||
|
|
|
@ -18,14 +18,15 @@ class OlympiamanagementsController < ApplicationController
|
||||||
rescue
|
rescue
|
||||||
@@error = nil
|
@@error = nil
|
||||||
end
|
end
|
||||||
if request.session[:olympia_login_id].to_s.blank?
|
@school = OlympiaSchoolDataFields.where(:account_number=>request.session[:olympia_login_id],:approved=>true).first rescue nil
|
||||||
|
if @school.nil?
|
||||||
render_contents_in_index_page(render_to_string(:formats=> [:html] ,:partial=>'login',:locals=>{:@error=>@@error})) and return
|
render_contents_in_index_page(render_to_string(:formats=> [:html] ,:partial=>'login',:locals=>{:@error=>@@error})) and return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def login
|
def login
|
||||||
@@error = nil
|
@@error = nil
|
||||||
if !params[:login_id].to_s.blank?
|
if !params[:login_id].to_s.blank?
|
||||||
if OlympiaSchoolDataFields.where(:account_number=>params[:login_id]).length == 0
|
if OlympiaSchoolDataFields.where(:account_number=>params[:login_id],:approved=>true).length == 0
|
||||||
@@error = "no_account"
|
@@error = "no_account"
|
||||||
else
|
else
|
||||||
if OlympiaSchoolDataFields.where(:account_number=>params[:login_id]).first.password != params[:login_pw]
|
if OlympiaSchoolDataFields.where(:account_number=>params[:login_id]).first.password != params[:login_pw]
|
||||||
|
@ -43,7 +44,7 @@ class OlympiamanagementsController < ApplicationController
|
||||||
end
|
end
|
||||||
def set_sign_up_setting
|
def set_sign_up_setting
|
||||||
@key = Site.first.template rescue "" #for_render_pages
|
@key = Site.first.template rescue "" #for_render_pages
|
||||||
@sign_up_setting = SignUpSetting.last
|
@sign_up_setting = SignUpSetting.where(:active=>true).last
|
||||||
data_arr = [{:url=>'/olympiamanagements/school_connection_data',:name=>t('olympiamanagement.school_connection_data')},
|
data_arr = [{:url=>'/olympiamanagements/school_connection_data',:name=>t('olympiamanagement.school_connection_data')},
|
||||||
{:url=>'/olympiamanagements/add_sign_up_student_data',:name=>t('olympiamanagement.add_sign_up_student_data')},
|
{:url=>'/olympiamanagements/add_sign_up_student_data',:name=>t('olympiamanagement.add_sign_up_student_data')},
|
||||||
{:url=>'/olympiamanagements/sign_up_student_data_list',:name=>t('olympiamanagement.sign_up_student_data_list')},
|
{:url=>'/olympiamanagements/sign_up_student_data_list',:name=>t('olympiamanagement.sign_up_student_data_list')},
|
||||||
|
@ -133,7 +134,21 @@ class OlympiamanagementsController < ApplicationController
|
||||||
@page_content = render_to_string(:formats=> [:html] ,:partial=>'login',:locals=>{:@error=>@error})
|
@page_content = render_to_string(:formats=> [:html] ,:partial=>'login',:locals=>{:@error=>@error})
|
||||||
else
|
else
|
||||||
@@error = nil
|
@@error = nil
|
||||||
|
@school_data_fields = [{'account_number'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true",'readonly'=>"readonly"}},
|
||||||
|
{'school_name'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true",'readonly'=>"readonly"}},
|
||||||
|
{'school_code'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true",'readonly'=>"readonly"}},
|
||||||
|
{'school_address'=>{'type'=>'String','size'=>'40','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true",'readonly'=>"readonly"}},
|
||||||
|
{'class_number'=>{'type'=>'String','size'=>'5','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true",'readonly'=>"readonly"}},
|
||||||
|
{'enrollment_limited'=>{'type'=>'Fixnum','size'=>'5','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true",'readonly'=>"readonly"}},
|
||||||
|
{'school_contact_person_name'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true"}},
|
||||||
|
{'department_job_title'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true"}},
|
||||||
|
{'office_tel_number'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true"}},
|
||||||
|
{'fax'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true"}},
|
||||||
|
{'mobile_number'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true"}},
|
||||||
|
{'email'=>{'type'=>'String','size'=>'40','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true"}}]
|
||||||
|
@olympia_school_data_field = OlympiaSchoolDataFields.where(:account_number=>@@session[:olympia_login_id]).first
|
||||||
@page_content = @breadcumb
|
@page_content = @breadcumb
|
||||||
|
@page_content += render_to_string(:formats=> [:html] ,:partial=>'edit_school_data_for_index.html',:locals=>{:@school_data_fields=>@school_data_fields,:@olympia_school_data_field=>@olympia_school_data_field,:@@session=>@@session}) #form_for not work for rendering in Pagescontroller => edit to form
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if !@instructions_pages.empty?
|
if !@instructions_pages.empty?
|
||||||
|
@ -207,7 +222,7 @@ class OlympiamanagementsController < ApplicationController
|
||||||
page_num = params[:page] || 1
|
page_num = params[:page] || 1
|
||||||
@field_infos = StudentDataField.first.student_data_fields
|
@field_infos = StudentDataField.first.student_data_fields
|
||||||
@olympia_school_data_fields_id = OlympiaSchoolDataFields.where(:account_number=>session[:olympia_login_id]).first.id
|
@olympia_school_data_fields_id = OlympiaSchoolDataFields.where(:account_number=>session[:olympia_login_id]).first.id
|
||||||
@sign_up_setting_id = SignUpSetting.last.id
|
@sign_up_setting_id = @sign_up_setting.id
|
||||||
@student_fields = OlympiaStudentDataField.where(:olympia_school_data_fields_id=>@olympia_school_data_fields_id,:sign_up_setting_id=>@sign_up_setting_id).asc(:id).page(page_num).per(10)
|
@student_fields = OlympiaStudentDataField.where(:olympia_school_data_fields_id=>@olympia_school_data_fields_id,:sign_up_setting_id=>@sign_up_setting_id).asc(:id).page(page_num).per(10)
|
||||||
@page_content = render_to_string(:formats=> [:html] ,:partial=>'student_data_list.html',:locals=>{:@student_fields=>(@student_fields rescue [])}).html_safe
|
@page_content = render_to_string(:formats=> [:html] ,:partial=>'student_data_list.html',:locals=>{:@student_fields=>(@student_fields rescue [])}).html_safe
|
||||||
render_contents_in_index_page(@breadcumb+@page_content)
|
render_contents_in_index_page(@breadcumb+@page_content)
|
||||||
|
@ -243,7 +258,10 @@ class OlympiamanagementsController < ApplicationController
|
||||||
@page = Page.where(:layout=>"olympia_managements_index",:parent_page_id=>(Page.where(:name=> ((I18n.locale.to_s == "en") ? "Home" : "首頁")).first.id)).first
|
@page = Page.where(:layout=>"olympia_managements_index",:parent_page_id=>(Page.where(:name=> ((I18n.locale.to_s == "en") ? "Home" : "首頁")).first.id)).first
|
||||||
data_arr = @page.child_page.map{|page| {:url=>"#{request.protocol}#{request.host_with_port}/#{I18n.locale}#{page.url}",:name=>page.name}}
|
data_arr = @page.child_page.map{|page| {:url=>"#{request.protocol}#{request.host_with_port}/#{I18n.locale}#{page.url}",:name=>page.name}}
|
||||||
@breadcumb = render_to_string(:formats=> [:html] ,:partial=>'breadcumb',:locals=>{:data_arr=>data_arr,:@title=>I18n.t('olympiamanagement.sign_up_title')})
|
@breadcumb = render_to_string(:formats=> [:html] ,:partial=>'breadcumb',:locals=>{:data_arr=>data_arr,:@title=>I18n.t('olympiamanagement.sign_up_title')})
|
||||||
@remark_texts =SignUpSetting.last.remark_field[I18n.locale.to_s].html_safe
|
@remark_texts = @sign_up_setting.remark_field[I18n.locale.to_s].html_safe
|
||||||
|
@sign_up_setting.attributes.to_h.each do |key,value|
|
||||||
|
@remark_texts = @remark_texts.gsub("{{#{key}}}",value.to_s)
|
||||||
|
end
|
||||||
@record_form_title = ((I18n.locale.to_s == "zh_tw") ? "#{Time.now.year}年國中科學奧林匹亞競賽國家代表隊選拔初選報名表" : "#{Time.now.year} Year International Junior Science Olympiad National Team Selection First Stage Sign up Form")
|
@record_form_title = ((I18n.locale.to_s == "zh_tw") ? "#{Time.now.year}年國中科學奧林匹亞競賽國家代表隊選拔初選報名表" : "#{Time.now.year} Year International Junior Science Olympiad National Team Selection First Stage Sign up Form")
|
||||||
@school_data = OlympiaSchoolDataFields.where(:account_number=>session[:olympia_login_id]).first
|
@school_data = OlympiaSchoolDataFields.where(:account_number=>session[:olympia_login_id]).first
|
||||||
@record_fields = [['school_name','school_code'],['school_address'],['class_number','enrollment_limited'],
|
@record_fields = [['school_name','school_code'],['school_address'],['class_number','enrollment_limited'],
|
||||||
|
@ -251,7 +269,7 @@ class OlympiamanagementsController < ApplicationController
|
||||||
@student_fields = ['serial_number','StudentName','StudentSex','StudentClass','StudentIDNO','birth_date','StudentArea','StudentIdentity']
|
@student_fields = ['serial_number','StudentName','StudentSex','StudentClass','StudentIDNO','birth_date','StudentArea','StudentIdentity']
|
||||||
@field_infos = StudentDataField.first.student_data_fields
|
@field_infos = StudentDataField.first.student_data_fields
|
||||||
@olympia_school_data_fields_id = OlympiaSchoolDataFields.where(:account_number=>session[:olympia_login_id]).first.id
|
@olympia_school_data_fields_id = OlympiaSchoolDataFields.where(:account_number=>session[:olympia_login_id]).first.id
|
||||||
@sign_up_setting_id = SignUpSetting.last.id
|
@sign_up_setting_id = @sign_up_setting.id
|
||||||
@student_data_list = OlympiaStudentDataField.where(:olympia_school_data_fields_id=>@olympia_school_data_fields_id,:sign_up_setting_id=>@sign_up_setting_id)
|
@student_data_list = OlympiaStudentDataField.where(:olympia_school_data_fields_id=>@olympia_school_data_fields_id,:sign_up_setting_id=>@sign_up_setting_id)
|
||||||
@head = render_to_string(:formats=>[:html],:file=>"#{Rails.root}/app/templates/#{@key}/partial/_head.html")
|
@head = render_to_string(:formats=>[:html],:file=>"#{Rails.root}/app/templates/#{@key}/partial/_head.html")
|
||||||
end
|
end
|
||||||
|
@ -264,7 +282,6 @@ class OlympiamanagementsController < ApplicationController
|
||||||
uid = OrbitHelper.params[:uid] rescue ""
|
uid = OrbitHelper.params[:uid] rescue ""
|
||||||
tags = OrbitHelper.widget_tags
|
tags = OrbitHelper.widget_tags
|
||||||
categories = OrbitHelper.widget_categories || []
|
categories = OrbitHelper.widget_categories || []
|
||||||
@sign_up_setting = SignUpSetting.last
|
|
||||||
@olympiamanagement_instruction = @sign_up_setting.registration_instructions[I18n.locale.to_s].to_s
|
@olympiamanagement_instruction = @sign_up_setting.registration_instructions[I18n.locale.to_s].to_s
|
||||||
@sign_up_setting.attributes.to_h.each do |key,value|
|
@sign_up_setting.attributes.to_h.each do |key,value|
|
||||||
@olympiamanagement_instruction = @olympiamanagement_instruction.gsub("{{#{key}}}",value.to_s)
|
@olympiamanagement_instruction = @olympiamanagement_instruction.gsub("{{#{key}}}",value.to_s)
|
||||||
|
@ -579,10 +596,8 @@ class OlympiamanagementsController < ApplicationController
|
||||||
if @error_msg.empty?
|
if @error_msg.empty?
|
||||||
@olympia_student_data = OlympiaStudentDataField.find(params[:id]) rescue nil
|
@olympia_student_data = OlympiaStudentDataField.find(params[:id]) rescue nil
|
||||||
if @olympia_student_data.nil?
|
if @olympia_student_data.nil?
|
||||||
@olympia_student_data = OlympiaStudentDataField.create(@student_params)
|
@olympia_student_data = OlympiaStudentDataField.create(@student_params.merge({
|
||||||
@olympia_student_data.olympia_school_data_fields_id = @olympia_school_data_field.id
|
:olympia_school_data_fields_id=>@olympia_school_data_field.id,:sign_up_setting_id => @sign_up_setting.id}))
|
||||||
@olympia_student_data.sign_up_setting_id = SignUpSetting.last.id
|
|
||||||
@olympia_student_data.save
|
|
||||||
else
|
else
|
||||||
@olympia_student_data.update_attributes(@student_params)
|
@olympia_student_data.update_attributes(@student_params)
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,6 +22,9 @@ class OlympiaSchoolDataFields
|
||||||
field :enrollment , type: Fixnum , default: 0
|
field :enrollment , type: Fixnum , default: 0
|
||||||
field :approved , type: Boolean , default: true
|
field :approved , type: Boolean , default: true
|
||||||
field :sign_up_setting_id , type: String , default: SignUpSetting.last.id.to_s
|
field :sign_up_setting_id , type: String , default: SignUpSetting.last.id.to_s
|
||||||
|
after_destroy do |record|
|
||||||
|
OlympiaStudentDataField.where(:olympia_school_data_fields_id => record.id,:sign_up_setting_id=>SignUpSetting.last.id).destroy_all
|
||||||
|
end
|
||||||
after_initialize do
|
after_initialize do
|
||||||
if !self.new_record?
|
if !self.new_record?
|
||||||
if self.approved.nil?
|
if self.approved.nil?
|
||||||
|
@ -32,6 +35,10 @@ class OlympiaSchoolDataFields
|
||||||
self.enrollment = 0
|
self.enrollment = 0
|
||||||
self.save!
|
self.save!
|
||||||
end
|
end
|
||||||
|
if self.enrollment == 0 #check enrollment student number
|
||||||
|
self.enrollment = OlympiaStudentDataField.where(:olympia_school_data_fields_id=>self.id,:sign_up_setting_id=>SignUpSetting.last.id).length
|
||||||
|
self.save!
|
||||||
|
end
|
||||||
if self.enrollment_limited.nil?
|
if self.enrollment_limited.nil?
|
||||||
self.enrollment_limited = 0
|
self.enrollment_limited = 0
|
||||||
self.save!
|
self.save!
|
||||||
|
|
|
@ -24,6 +24,24 @@ class OlympiaStudentDataField
|
||||||
field :sign_up_setting_id , type: String , default: ''
|
field :sign_up_setting_id , type: String , default: ''
|
||||||
has_many :olympia_student_images , :dependent => :destroy , autosave: true
|
has_many :olympia_student_images , :dependent => :destroy , autosave: true
|
||||||
after_save :check_file
|
after_save :check_file
|
||||||
|
after_create do |record|
|
||||||
|
if !record.olympia_school_data_fields_id.blank?
|
||||||
|
@school = OlympiaSchoolDataFields.find(record.olympia_school_data_fields_id) rescue nil
|
||||||
|
if !@school.nil?
|
||||||
|
@school.enrollment = @school.enrollment + 1
|
||||||
|
@school.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
after_destroy do |record|
|
||||||
|
if !record.olympia_school_data_fields_id.blank?
|
||||||
|
@school = OlympiaSchoolDataFields.find(record.olympia_school_data_fields_id) rescue nil
|
||||||
|
if !@school.nil?
|
||||||
|
@school.enrollment = @school.enrollment - 1
|
||||||
|
@school.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
after_initialize do
|
after_initialize do
|
||||||
if !self.new_record?
|
if !self.new_record?
|
||||||
if self.approved.nil?
|
if self.approved.nil?
|
||||||
|
|
|
@ -18,9 +18,13 @@ class SignUpSetting
|
||||||
field :end_minute , type: String , default: Time.now.strftime("%M")
|
field :end_minute , type: String , default: Time.now.strftime("%M")
|
||||||
field :default_password , type: String , default: ""
|
field :default_password , type: String , default: ""
|
||||||
field :set_default_password , type: Boolean , default: false
|
field :set_default_password , type: Boolean , default: false
|
||||||
field :remark_field , type: Hash , default: {:zh_tw=>"",:en=>""}
|
field :remark_field , type: Hash , default: {:zh_tw=>"<strong><span style="font-size: 14pt"><span style="font-family: arial, helvetica, sans-serif">注意事項:</span></span></strong><span style="font-size: 14pt"><br />
|
||||||
|
請於<strong><span style="color: rgb(255,0,0)">2019年5月3日前</span></strong>(以郵戳為憑),將本報名表正本(需核章)以掛號方式郵寄至【<strong><span style="color: rgb(0,0,255)">11677台北市文山區汀州路4段88號科教中心,收件人: IJSO選訓委員會</span></strong>】,逾期概不受理報名。 <br />
|
||||||
|
<br type="_moz" />
|
||||||
|
</span><br />",:en=>""}
|
||||||
field :registration_instructions , type: Hash , default: {:zh_tw=>"",:en=>""}
|
field :registration_instructions , type: Hash , default: {:zh_tw=>"",:en=>""}
|
||||||
after_save :change_all_password
|
field :active , type: Boolean , default: true
|
||||||
|
after_save :change_all_password , :check_active
|
||||||
def change_all_password
|
def change_all_password
|
||||||
if self.set_default_password
|
if self.set_default_password
|
||||||
OlympiaSchoolDataFields.all.each do |school_field|
|
OlympiaSchoolDataFields.all.each do |school_field|
|
||||||
|
@ -31,4 +35,11 @@ class SignUpSetting
|
||||||
self.save
|
self.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
def check_active
|
||||||
|
if self.active
|
||||||
|
SignUpSetting.where.not(:id=>self.id).each do |setting|
|
||||||
|
setting.active = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -0,0 +1,15 @@
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
wb = xlsx_package.workbook
|
||||||
|
wb.add_worksheet(name: "school_class") do |sheet|
|
||||||
|
row = []
|
||||||
|
title = sheet.styles.add_style(:bg_color => "FFFF00",:border=>{ :style => :thin, :color => "666666" },:alignment=>{ :horizontal => :center,:vertical => :center ,:wrap_text => true})
|
||||||
|
column = sheet.styles.add_style(:alignment=>{ :horizontal => :center,:vertical => :center ,:wrap_text => true},:border=>{ :style => :thin, :color => "666666" })
|
||||||
|
@fields.each do |field|
|
||||||
|
row << t('olympiamanagement.'+field)
|
||||||
|
end
|
||||||
|
sheet.add_row row , :style=> title,:widths => row.map{|cell| (cell.length* 11/ 2).round}
|
||||||
|
@student_data_list.each do |infos_row|
|
||||||
|
sheet.add_row infos_row , :style=> column
|
||||||
|
end
|
||||||
|
end
|
|
@ -2,6 +2,10 @@
|
||||||
<link rel="stylesheet" media="print" type="text/css" href="/assets/admin/olympiamanagement.scss">
|
<link rel="stylesheet" media="print" type="text/css" href="/assets/admin/olympiamanagement.scss">
|
||||||
<script src="/assets/admin/olympiamanagement.js"></script>
|
<script src="/assets/admin/olympiamanagement.js"></script>
|
||||||
<% th_name_list = ['StudentName','StudentSex','StudentClass','birth_date','StudentIdentity','StudentArea','scan_file_of_certificate','action']%>
|
<% th_name_list = ['StudentName','StudentSex','StudentClass','birth_date','StudentIdentity','StudentArea','scan_file_of_certificate','action']%>
|
||||||
|
<% @school = (OlympiaSchoolDataFields.find(params[:olympia_school_id]) rescue nil) %>
|
||||||
|
<% if !@school.nil? %>
|
||||||
|
<h3><%= "#{t('olympiamanagement.school_name')}:#{@school.school_name}".html_safe %></h3>
|
||||||
|
<% end %>
|
||||||
<table cellspacing="0" class="ts_rowsonly" width="100%" id="RSS_Table_page_contest_admin_1">
|
<table cellspacing="0" class="ts_rowsonly" width="100%" id="RSS_Table_page_contest_admin_1">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -18,7 +22,7 @@
|
||||||
<td><%= "#{field.StudentBirthYear}-#{field.StudentBirthMonth}-#{field.StudentBirthDay}" %></td>
|
<td><%= "#{field.StudentBirthYear}-#{field.StudentBirthMonth}-#{field.StudentBirthDay}" %></td>
|
||||||
<% elsif th_name == 'scan_file_of_certificate'%>
|
<% elsif th_name == 'scan_file_of_certificate'%>
|
||||||
<% if !field.olympia_student_images.map{|image| image.student_file.file}.select { |file| file.present?}.empty? %>
|
<% if !field.olympia_student_images.map{|image| image.student_file.file}.select { |file| file.present?}.empty? %>
|
||||||
<td><a href='<%="#{admin_olympiamanagements_download_scan_file_of_certificate_path}?student_id=#{field.id}" %>'><%= "#{field.StudentName}.gif" %><img src="/assets/gif.gif" border="0" alt="<%= "#{field.StudentName}.gif" %>"></a></td>
|
<td><a href='<%="#{admin_olympiamanagements_download_scan_file_of_certificate_path}?student_id=#{field.id}" %>'><%= "#{field.StudentName}.jpg" %><img src="/assets/gif.gif" border="0" alt="<%= "#{field.StudentName}.jpg" %>"></a></td>
|
||||||
<% else %>
|
<% else %>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<link rel="stylesheet" media="screen" type="text/css" href="/assets/admin/olympiamanagement.scss">
|
||||||
|
<link rel="stylesheet" media="print" type="text/css" href="/assets/admin/olympiamanagement.scss">
|
||||||
|
<script src="/assets/admin/olympiamanagement.js"></script>
|
||||||
|
<fieldset class="fieldset_block">
|
||||||
|
<legend class="fieldset_title"><%=t('olympiamanagement.school_connection_data')%></legend>
|
||||||
|
<form action="/olympiamanagements/update_school_data" method="post">
|
||||||
|
<input type="hidden" name="authenticity_token" value="<%= @@session[:_csrf_token] %>">
|
||||||
|
<input type="hidden" name="utf8" value="✓">
|
||||||
|
<input type="hidden" name="olympia_user_name" value="<%=@@session[:olympia_login_id] rescue ""%>">
|
||||||
|
<% @school_data_fields.each do |field| %>
|
||||||
|
<div class="col_text">
|
||||||
|
<% @extra_class = ((field.values[0]["required"] == "true")? " required" : "")%>
|
||||||
|
<% @extra_text = ((field.values[0]["required"] == "true")? "*" : "")%>
|
||||||
|
<li class="col<%=@extra_class%>" for="<%=field.keys[0]%>"><%= @extra_text+t('olympiamanagement.'+field.keys[0]) %></li><li class="col_r">
|
||||||
|
<% if field.values[0]["type"] != 'select' %>
|
||||||
|
<input name="<%="[add_school_data][#{field.keys[0]}]"%>" value="<%= (field.keys[0]=="enrollment_limited"&&(@olympia_school_data_field[field.keys[0]].nil? || @olympia_school_data_field[field.keys[0]] == 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 : @olympia_school_data_field[field.keys[0]] %>" size="<%=field.values[0]["size"]%>" type="text" id="<%= field.keys[0] %>" class="col_input<%= @extra_class%>" <%=field.values[0]["readonly"]%>/>
|
||||||
|
<% else%>
|
||||||
|
<% @please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please select." %>
|
||||||
|
<select name="<%="[add_school_data][#{field.keys[0]}]"%>" id="<%=field.keys[0]%>" class="required" value="<%= @olympia_school_data_field[field.keys[0]] %>" style="width: auto;"><option value=""><%=@please_choice%></option>
|
||||||
|
<% for @num in field.values[0]["range"][0] .. field.values[0]["range"][1] %>
|
||||||
|
<%= ('<option value="' + @num.to_s + '">' + @num.to_s + field.values[0][:unit][I18n.locale.to_s] + '</option>').html_safe %>
|
||||||
|
<% end %>
|
||||||
|
</select>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
|
<% if(!field.values[0]["hint"][I18n.locale.to_s].blank? rescue false) %>
|
||||||
|
<span id="-H" class="field-hint-inactive"><%=field.values[0][:hint][I18n.locale.to_s]%></span>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<div style="clear:both;"></div>
|
||||||
|
<input type="submit" name="Submit" value="<%=t('olympiamanagement.confirm')%>">
|
||||||
|
<input type="reset" name="Submit" value="<%=t('olympiamanagement.cancel')%>">
|
||||||
|
</form>
|
||||||
|
</fieldset>
|
Loading…
Reference in New Issue