From 5360ed4d3a400ca0000c426a4ffbc80be250dddb Mon Sep 17 00:00:00 2001 From: p31729568 Date: Mon, 20 May 2019 11:23:45 +0800 Subject: [PATCH] fix save school fail bug --- app/controllers/colleges_controller.rb | 6 +++--- app/controllers/managements/schools_controller.rb | 10 +++++----- app/controllers/managements_controller.rb | 2 +- app/views/managements/upload_logo.html.erb | 5 ++++- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/controllers/colleges_controller.rb b/app/controllers/colleges_controller.rb index 960030c9..fff508a8 100644 --- a/app/controllers/colleges_controller.rb +++ b/app/controllers/colleges_controller.rb @@ -31,9 +31,9 @@ class CollegesController < ApplicationController end def verification_school_identifier - school = School.where(:identifier => params[:identifier]).first - status = school.present? ? 1 : 0 - render :json => {status: status} + schools = School.where(identifier: params[:identifier]) + schools = schools.where('id != ?', params[:school_id]) if params[:school_id].present? + render :json => { status: schools.exists? ? 1 : 0 } end def online_school diff --git a/app/controllers/managements/schools_controller.rb b/app/controllers/managements/schools_controller.rb index f27e00ae..a5c789ff 100644 --- a/app/controllers/managements/schools_controller.rb +++ b/app/controllers/managements/schools_controller.rb @@ -4,8 +4,8 @@ class Managements::SchoolsController < Managements::BaseController def statistics @sub_type = 1 - params[:sort_by] = :teacher_count if params[:sort_by].blank? - params[:sort_direction] = :desc if params[:sort_direction].blank? + params[:sort_by] = params[:sort_by].presence || :teacher_count + params[:sort_direction] = params[:sort_direction].presence || :desc service = Management::SchoolReportService.new(params) @obj_count, @schools = service.call @@ -20,8 +20,8 @@ class Managements::SchoolsController < Managements::BaseController def data_grow @sub_type = 2 params[:data_type] ||= 'grow' - params[:sort_by] = :teacher_increase_count if params[:sort_by].blank? - params[:sort_direction] = :desc if params[:sort_direction].blank? + params[:sort_by] = params[:sort_by].presence || :teacher_increase_count + params[:sort_direction] = params[:sort_direction].presence || :desc service = Management::SchoolDataGrowService.new(params) @grow_summary = service.grow_summary @@ -31,7 +31,7 @@ class Managements::SchoolsController < Managements::BaseController end 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_by] = :percentage diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index f67099b9..1eab7439 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1518,7 +1518,7 @@ end if search.blank? @schools = School.where("0=0") else - @schools = School.where("name like '%#{search}%'") + @schools = School.where("name like ?", "%#{search}%") end if params[:index] == '8' @schools = @schools.reorder("created_at #{@sx_order}") diff --git a/app/views/managements/upload_logo.html.erb b/app/views/managements/upload_logo.html.erb index 5da56c47..487f3eba 100644 --- a/app/views/managements/upload_logo.html.erb +++ b/app/views/managements/upload_logo.html.erb @@ -130,7 +130,10 @@ if($("#unit_head_route").val().trim() !=""){ $.ajax({ 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, success: function (data) { if(data.status == 0){