fix bugs in version 1
This commit is contained in:
parent
660716e8c7
commit
9ec22c3487
|
@ -1,13 +1,14 @@
|
||||||
PATH
|
PATH
|
||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
cancerpredict (0.0.1)
|
olympiamanagement (0.0.1)
|
||||||
mongoid (= 4.0.0.beta1)
|
mongoid (= 4.0.0.beta1)
|
||||||
rails (~> 4.1.0.rc2)
|
rails (~> 4.1.0.rc2)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
|
rubyXL (~> 3.4.6)
|
||||||
actionmailer (4.1.0.rc2)
|
actionmailer (4.1.0.rc2)
|
||||||
actionpack (= 4.1.0.rc2)
|
actionpack (= 4.1.0.rc2)
|
||||||
actionview (= 4.1.0.rc2)
|
actionview (= 4.1.0.rc2)
|
||||||
|
|
|
@ -1,42 +1,4 @@
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$('.class_setting_block input[type="reset"]').off('click').on('click',function(){
|
|
||||||
$('.col_input').val('');
|
|
||||||
});
|
|
||||||
$('.class_setting_block input[type="submit"]').off('click').on('click',function(){
|
|
||||||
var class_number_range = [];
|
|
||||||
class_number_range.push(Number($('.class_setting_block .col_input[name="MinClass"]').val()));
|
|
||||||
class_number_range.push(Number($('.class_setting_block .col_input[name="MaxClass"]').val()));
|
|
||||||
var enrollment_available = $('.class_setting_block .col_input#Person').val();
|
|
||||||
class_number_range.sort();
|
|
||||||
var params_array = (window.location.search.substring(1)=="") ? [] : window.location.search.substring(1).split('&').map(function(el){return el.split('=')});
|
|
||||||
var params = {};
|
|
||||||
params_array.forEach(function(el){params[el[0]] = el[1]});
|
|
||||||
var params_to_send = {'type':'class_setting','class_number_range':class_number_range,'enrollment_available':enrollment_available};
|
|
||||||
params_to_send = Object.assign(params,params_to_send);
|
|
||||||
var post_data = $.post('/admin/olympiamanagements/update_school_data',params_to_send);
|
|
||||||
post_data.done(function(){
|
|
||||||
window.location.search="";
|
|
||||||
});
|
|
||||||
});
|
|
||||||
$('.class_setting_block input').keypress(function(event){
|
|
||||||
var keycode = event['keyCode'] || event['which'];
|
|
||||||
if(Number(keycode) == 13){
|
|
||||||
var class_number_range = [];
|
|
||||||
class_number_range.push(Number($('.class_setting_block .col_input[name="MinClass"]').val()));
|
|
||||||
class_number_range.push(Number($('.class_setting_block .col_input[name="MaxClass"]').val()));
|
|
||||||
var enrollment_available = $('.class_setting_block .col_input#Person').val();
|
|
||||||
class_number_range.sort();
|
|
||||||
var params_array = (window.location.search.substring(1)=="") ? [] : window.location.search.substring(1).split('&').map(function(el){return el.split('=')});
|
|
||||||
var params = {};
|
|
||||||
params_array.forEach(function(el){params[el[0]] = el[1]});
|
|
||||||
var params_to_send = {'type':'class_setting','class_number_range':class_number_range,'enrollment_available':enrollment_available};
|
|
||||||
params_to_send = Object.assign(params,params_to_send);
|
|
||||||
var post_data = $.post('/admin/olympiamanagements/update_school_data',params_to_send);
|
|
||||||
post_data.done(function(){
|
|
||||||
window.location.search="";
|
|
||||||
});
|
|
||||||
};
|
|
||||||
});
|
|
||||||
$('.fieldset_block input[type="submit"]').click(function(){
|
$('.fieldset_block input[type="submit"]').click(function(){
|
||||||
$el = $('.fieldset_block li.required');
|
$el = $('.fieldset_block li.required');
|
||||||
for(var i = 0; i< $el.length ; i++){
|
for(var i = 0; i< $el.length ; i++){
|
||||||
|
|
|
@ -143,5 +143,28 @@ $(document).ready(function(){
|
||||||
}else{
|
}else{
|
||||||
$('#StudentFile').addClass('required');
|
$('#StudentFile').addClass('required');
|
||||||
};
|
};
|
||||||
|
$el = $('.fieldset_block li[for="StudentFile"]');
|
||||||
|
if($el.siblings('.col_r').find('.required').val() == ""){
|
||||||
|
$el.addClass('errFld');
|
||||||
|
if($el.siblings('.col_r').find('.errMsg').length == 0)
|
||||||
|
$el.siblings('.col_r').append('<div id="SchoolName-E" class="errMsg"> '+((I18n.locale == "en") ? 'Required field': '必填欄位')+'</div>');
|
||||||
|
}else{
|
||||||
|
$el.removeClass('errFld');
|
||||||
|
$el.siblings('.col_r').find('.errMsg').remove();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
$('#StudentFile').on('input',function(){
|
||||||
|
if($(this).val() != ''){
|
||||||
|
$('[for="StudentFile"]').removeClass('errFld');
|
||||||
|
$('[for="StudentFile"]').siblings('.col_r').find('.errMsg').remove();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
$('[data-dismiss="fileupload"]').click(function(){
|
||||||
|
if($('#StudentFile').hasClass('required')){
|
||||||
|
$el = $('.fieldset_block li[for="StudentFile"]');
|
||||||
|
$el.addClass('errFld');
|
||||||
|
if($el.siblings('.col_r').find('.errMsg').length == 0)
|
||||||
|
$el.siblings('.col_r').append('<div id="SchoolName-E" class="errMsg"> '+((I18n.locale == "en") ? 'Required field': '必填欄位')+'</div>');
|
||||||
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -66,6 +66,12 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
||||||
@ClassSettingField.enrollment_available = params[:enrollment_available].to_i
|
@ClassSettingField.enrollment_available = params[:enrollment_available].to_i
|
||||||
@ClassSettingField.save
|
@ClassSettingField.save
|
||||||
render :json => {'success'=>true} and return
|
render :json => {'success'=>true} and return
|
||||||
|
elsif params[:type] == 'class_setting_for_form'
|
||||||
|
@ClassSettingField = (params[:id].nil? ? ClassSettingFields.new : ((ClassSettingFields.find(params[:id]).nil? rescue true) ? ClassSettingFields.new : ClassSettingFields.find(params[:id])))
|
||||||
|
@ClassSettingField.class_number_range = [params[:MinClass],params[:MaxClass]].map{|str| str.to_i}.sort
|
||||||
|
@ClassSettingField.enrollment_available = params[:Person].to_i
|
||||||
|
@ClassSettingField.save
|
||||||
|
redirect_to admin_olympiamanagements_class_setting_path
|
||||||
elsif params[:type] == 'delete_class_setting'
|
elsif params[:type] == 'delete_class_setting'
|
||||||
if !params[:id].to_s.blank?
|
if !params[:id].to_s.blank?
|
||||||
begin
|
begin
|
||||||
|
@ -197,12 +203,10 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
||||||
flag = 0
|
flag = 0
|
||||||
else
|
else
|
||||||
#@error_msg << @row_index_hash and return false
|
#@error_msg << @row_index_hash and return false
|
||||||
@olympia_school_data_field = OlympiaSchoolDataFields.where(:school_code=> row[@row_index_hash["school_code"]]).first
|
@olympia_school_data_field = OlympiaSchoolDataFields.where(:school_code=> row[@row_index_hash["school_code"]],:sign_up_setting_id=>@sign_up_setting.id).first
|
||||||
@olympia_school_data_field = OlympiaSchoolDataFields.new() if @olympia_school_data_field.nil?
|
@olympia_school_data_field = OlympiaSchoolDataFields.new() if @olympia_school_data_field.nil?
|
||||||
@row_index_hash.each do |key,index|
|
@update_attributes = @row_index_hash.map{|key,index| [key,row[index]]}.to_h
|
||||||
@olympia_school_data_field[key] = row[index]
|
@olympia_school_data_field.update_attributes(@update_attributes)
|
||||||
end
|
|
||||||
@olympia_school_data_field.save
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
|
@ -428,7 +432,10 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
||||||
@olympia_school_data_field = OlympiaSchoolDataFields.find(params[:school_id]) rescue nil
|
@olympia_school_data_field = OlympiaSchoolDataFields.find(params[:school_id]) rescue nil
|
||||||
@enrollment_limited = ((@olympia_school_data_field.enrollment_limited.nil? || @olympia_school_data_field.enrollment_limited == 0) ? ClassSettingFields.all.select{|class_setting_field| class_setting_field.class_number_range[0] <= @olympia_school_data_field.class_number.to_i && class_setting_field.class_number_range[1] >= @olympia_school_data_field.class_number.to_i}.first.enrollment_available.to_i : @olympia_school_data_field.enrollment_limited.to_i)
|
@enrollment_limited = ((@olympia_school_data_field.enrollment_limited.nil? || @olympia_school_data_field.enrollment_limited == 0) ? ClassSettingFields.all.select{|class_setting_field| class_setting_field.class_number_range[0] <= @olympia_school_data_field.class_number.to_i && class_setting_field.class_number_range[1] >= @olympia_school_data_field.class_number.to_i}.first.enrollment_available.to_i : @olympia_school_data_field.enrollment_limited.to_i)
|
||||||
@student_fields = OlympiaStudentDataField.where(:olympia_school_data_fields_id=>params[:school_id],:sign_up_setting_id=>@sign_up_setting_id)
|
@student_fields = OlympiaStudentDataField.where(:olympia_school_data_fields_id=>params[:school_id],:sign_up_setting_id=>@sign_up_setting_id)
|
||||||
if @student_fields.length > @enrollment_limited
|
@olympia_student_data = OlympiaStudentDataField.find(params[:id]) rescue nil
|
||||||
|
extra_num = 0
|
||||||
|
extra_num = 1 if(@olympia_student_data.nil? && @student_params['StudentIdentity'] != '1')
|
||||||
|
if (@student_fields.length + extra_num) > @enrollment_limited
|
||||||
@error_msg << ((I18n.locale.to_s == "zh_tw") ? ("一般身分報名人數上限為 #{@enrollment_limited} 人。") : ("Enrollment limited of General identity is #{@enrollment_limited} people."))
|
@error_msg << ((I18n.locale.to_s == "zh_tw") ? ("一般身分報名人數上限為 #{@enrollment_limited} 人。") : ("Enrollment limited of General identity is #{@enrollment_limited} people."))
|
||||||
@error_msg << I18n.t('olympiamanagement.already_exceed_enrollment_limited')
|
@error_msg << I18n.t('olympiamanagement.already_exceed_enrollment_limited')
|
||||||
end
|
end
|
||||||
|
@ -474,7 +481,7 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def download_import_file
|
def download_import_file
|
||||||
@OlympiaSchoolDataFields = OlympiaSchoolDataFields.all.asc(:id)
|
@OlympiaSchoolDataFields = OlympiaSchoolDataFields.where(:sign_up_setting_id=>@sign_up_setting.id).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
|
||||||
|
|
|
@ -677,13 +677,16 @@ 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['olympia_student_images']['0']['StudentFile'].nil? rescue true)
|
if @student_params['StudentIdentity'] == '1' && (@student_params['olympia_student_images']['0']['student_file'].nil? rescue true)
|
||||||
@error_msg << I18n.t('olympiamanagement.StudentFile')
|
@error_msg << I18n.t('olympiamanagement.StudentFile')
|
||||||
end
|
end
|
||||||
@olympia_school_data_field = OlympiaSchoolDataFields.where(:account_number=>session[:olympia_login_id],:sign_up_setting_id=>@sign_up_setting.id,:approved=>true).first
|
@olympia_school_data_field = OlympiaSchoolDataFields.where(:account_number=>session[:olympia_login_id],:sign_up_setting_id=>@sign_up_setting.id,:approved=>true).first
|
||||||
@enrollment_limited = ((@olympia_school_data_field.enrollment_limited.nil? || @olympia_school_data_field.enrollment_limited == 0) ? ClassSettingFields.all.select{|class_setting_field| class_setting_field.class_number_range[0] <= @olympia_school_data_field.class_number.to_i && class_setting_field.class_number_range[1] >= @olympia_school_data_field.class_number.to_i}.first.enrollment_available.to_i : @olympia_school_data_field.enrollment_limited.to_i)
|
@enrollment_limited = ((@olympia_school_data_field.enrollment_limited.nil? || @olympia_school_data_field.enrollment_limited == 0) ? ClassSettingFields.all.select{|class_setting_field| class_setting_field.class_number_range[0] <= @olympia_school_data_field.class_number.to_i && class_setting_field.class_number_range[1] >= @olympia_school_data_field.class_number.to_i}.first.enrollment_available.to_i : @olympia_school_data_field.enrollment_limited.to_i)
|
||||||
@student_fields = OlympiaStudentDataField.where(:olympia_school_data_fields_id=>@olympia_school_data_field.id,:sign_up_setting_id=>@sign_up_setting.id)
|
@student_fields = OlympiaStudentDataField.where(:olympia_school_data_fields_id=>@olympia_school_data_field.id,:sign_up_setting_id=>@sign_up_setting.id,:StudentIdentity=>'0')
|
||||||
if @student_fields.length > @enrollment_limited
|
@olympia_student_data = OlympiaStudentDataField.find(params[:id]) rescue nil
|
||||||
|
extra_num = 0
|
||||||
|
extra_num = 1 if(@olympia_student_data.nil? && @student_params['StudentIdentity'] != '1')
|
||||||
|
if (@student_fields.length + extra_num) > @enrollment_limited
|
||||||
@error_msg << ((I18n.locale.to_s == "zh_tw") ? ("一般身分報名人數上限為 #{@enrollment_limited} 人。") : ("Enrollment limited of General identity is #{@enrollment_limited} people."))
|
@error_msg << ((I18n.locale.to_s == "zh_tw") ? ("一般身分報名人數上限為 #{@enrollment_limited} 人。") : ("Enrollment limited of General identity is #{@enrollment_limited} people."))
|
||||||
@error_msg << I18n.t('olympiamanagement.already_exceed_enrollment_limited')
|
@error_msg << I18n.t('olympiamanagement.already_exceed_enrollment_limited')
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,19 +2,21 @@
|
||||||
<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>
|
||||||
<fieldset class="fieldset_block class_setting_block">
|
<fieldset class="fieldset_block class_setting_block">
|
||||||
<legend class="fieldset_title"><%=t('olympiamanagement.class_setting')%></legend>
|
<%= form_tag admin_olympiamanagements_update_school_data_path(:type => "class_setting_for_form") do %>
|
||||||
<div class="col_text">
|
<legend class="fieldset_title"><%=t('olympiamanagement.class_setting')%></legend>
|
||||||
<li class="col" for="MinClass"><%= t('olympiamanagement.class_number')+"(#{t('olympiamanagement.spacing')})"%></li>
|
<div class="col_text">
|
||||||
<li class="col_r"><input name="MinClass" type="text" id="MinClass" size="5" class="col_input" <%= @ClassSettingField.nil? ? nil : "value=#{@ClassSettingField.class_number_range[0]}"%>></li>
|
<li class="col" for="MinClass"><%= t('olympiamanagement.class_number')+"(#{t('olympiamanagement.spacing')})"%></li>
|
||||||
<span style="float:left;">~</span>
|
<li class="col_r"><input name="MinClass" type="text" id="MinClass" size="5" class="col_input" <%= @ClassSettingField.nil? ? nil : "value=#{@ClassSettingField.class_number_range[0]}"%>></li>
|
||||||
<li class="col_r"><input name="MaxClass" type="text" id="MaxClass" size="5" class="col_input" <%= @ClassSettingField.nil? ? nil : "value=#{@ClassSettingField.class_number_range[1]}"%>></li>
|
<span style="float:left;">~</span>
|
||||||
</div>
|
<li class="col_r"><input name="MaxClass" type="text" id="MaxClass" size="5" class="col_input" <%= @ClassSettingField.nil? ? nil : "value=#{@ClassSettingField.class_number_range[1]}"%>></li>
|
||||||
<div class="col_text">
|
</div>
|
||||||
<li class="col" for="Person"><%= t('olympiamanagement.enrollment_available') %></li><li class="col_r"><input name="Person" type="text" id="Person" size="5" class="col_input" <%= @ClassSettingField.nil? ? nil : "value=#{@ClassSettingField.enrollment_available}"%>></li>
|
<div class="col_text">
|
||||||
</div>
|
<li class="col" for="Person"><%= t('olympiamanagement.enrollment_available') %></li><li class="col_r"><input name="Person" type="text" id="Person" size="5" class="col_input" <%= @ClassSettingField.nil? ? nil : "value=#{@ClassSettingField.enrollment_available}"%>></li>
|
||||||
<div style="clear:both;"></div>
|
</div>
|
||||||
<input type="submit" name="Submit" value="<%=t('olympiamanagement.confirm')%>">
|
<div style="clear:both;"></div>
|
||||||
<input type="reset" name="Submit" value="<%=t('olympiamanagement.cancel')%>">
|
<input type="submit" name="Submit" value="<%=t('olympiamanagement.confirm')%>">
|
||||||
|
<input type="reset" name="Submit" value="<%=t('olympiamanagement.cancel')%>">
|
||||||
|
<% end %>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<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>
|
||||||
|
|
Loading…
Reference in New Issue