fix save school fail bug

dev_ec
p31729568 6 years ago
parent 2374e6f31c
commit 5360ed4d3a

@ -31,9 +31,9 @@ class CollegesController < ApplicationController
end end
def verification_school_identifier def verification_school_identifier
school = School.where(:identifier => params[:identifier]).first schools = School.where(identifier: params[:identifier])
status = school.present? ? 1 : 0 schools = schools.where('id != ?', params[:school_id]) if params[:school_id].present?
render :json => {status: status} render :json => { status: schools.exists? ? 1 : 0 }
end end
def online_school def online_school

@ -4,8 +4,8 @@ class Managements::SchoolsController < Managements::BaseController
def statistics def statistics
@sub_type = 1 @sub_type = 1
params[:sort_by] = :teacher_count if params[:sort_by].blank? params[:sort_by] = params[:sort_by].presence || :teacher_count
params[:sort_direction] = :desc if params[:sort_direction].blank? params[:sort_direction] = params[:sort_direction].presence || :desc
service = Management::SchoolReportService.new(params) service = Management::SchoolReportService.new(params)
@obj_count, @schools = service.call @obj_count, @schools = service.call
@ -20,8 +20,8 @@ class Managements::SchoolsController < Managements::BaseController
def data_grow def data_grow
@sub_type = 2 @sub_type = 2
params[:data_type] ||= 'grow' params[:data_type] ||= 'grow'
params[:sort_by] = :teacher_increase_count if params[:sort_by].blank? params[:sort_by] = params[:sort_by].presence || :teacher_increase_count
params[:sort_direction] = :desc if params[:sort_direction].blank? params[:sort_direction] = params[:sort_direction].presence || :desc
service = Management::SchoolDataGrowService.new(params) service = Management::SchoolDataGrowService.new(params)
@grow_summary = service.grow_summary @grow_summary = service.grow_summary
@ -31,7 +31,7 @@ class Managements::SchoolsController < Managements::BaseController
end end
def data_contrast def data_contrast
params[:contrast_column] = :teacher_increase_count if params[:contrast_column].blank? params[:contrast_column] = params[:contrast_column].presence || :teacher_increase_count
params[:sort_direction] ||= :desc params[:sort_direction] ||= :desc
params[:sort_by] = :percentage params[:sort_by] = :percentage

@ -1518,7 +1518,7 @@ end
if search.blank? if search.blank?
@schools = School.where("0=0") @schools = School.where("0=0")
else else
@schools = School.where("name like '%#{search}%'") @schools = School.where("name like ?", "%#{search}%")
end end
if params[:index] == '8' if params[:index] == '8'
@schools = @schools.reorder("created_at #{@sx_order}") @schools = @schools.reorder("created_at #{@sx_order}")

@ -130,7 +130,10 @@
if($("#unit_head_route").val().trim() !=""){ if($("#unit_head_route").val().trim() !=""){
$.ajax({ $.ajax({
url: "<%= verification_school_identifier_colleges_path %>", url: "<%= verification_school_identifier_colleges_path %>",
data: {identifier: $("#unit_head_route").val().trim()}, data: {
school_id: <%= @school.id %>,
identifier: $("#unit_head_route").val().trim()
},
async:false, async:false,
success: function (data) { success: function (data) {
if(data.status == 0){ if(data.status == 0){

Loading…
Cancel
Save