|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
class EcsController < ApplicationController
|
|
|
|
|
before_filter :find_school, :except => [:get_navigation_url]
|
|
|
|
|
before_filter :require_login
|
|
|
|
|
before_filter :ec_auth, :except => [:get_navigation_url]
|
|
|
|
|
before_filter :find_school, :except => [:get_navigation_url]
|
|
|
|
|
before_filter :school_manager, :except => [:department, :get_navigation_url]
|
|
|
|
|
layout 'base_ec'
|
|
|
|
|
|
|
|
|
|
def department
|
|
|
|
@ -12,12 +12,15 @@ class EcsController < ApplicationController
|
|
|
|
|
@major_schools = @school.ec_major_schools.where(:template_major => false)
|
|
|
|
|
unless @is_school_manager
|
|
|
|
|
ec_major_school_ids = EcMajorSchoolUser.where(:user_id => User.current.id).pluck(:ec_major_school_id)
|
|
|
|
|
ec_course_major_ids = EcYear.where(:id => EcCourseUser.where(:user_id => User.current.id).pluck(:ec_year_id)).pluck(:ec_major_school_id)
|
|
|
|
|
ec_course_major_ids = EcYear.where(:id => EcCourse.where(:id => EcCourseUser.where(:user_id => User.current.id).pluck(:ec_course_id)).pluck(:ec_year_id)).pluck(:ec_major_school_id)
|
|
|
|
|
@major_schools = @major_schools.where(:id => (ec_major_school_ids + ec_course_major_ids).uniq)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@major_count = @major_schools.count
|
|
|
|
|
|
|
|
|
|
if @major_count == 0
|
|
|
|
|
render_403
|
|
|
|
|
else
|
|
|
|
|
if params[:search].present?
|
|
|
|
|
major_ids = EcMajor.where("name like '%#{params[:search]}%' or code like '%#{params[:search]}%'").pluck(:id)
|
|
|
|
|
@major_schools = @major_schools.where(:ec_major_id => major_ids)
|
|
|
|
@ -34,6 +37,7 @@ class EcsController < ApplicationController
|
|
|
|
|
format.html
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 搜索专业
|
|
|
|
|
def search_major
|
|
|
|
@ -65,9 +69,8 @@ class EcsController < ApplicationController
|
|
|
|
|
@school = School.find(params[:school_id])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 职业认证的权限判断
|
|
|
|
|
def ec_auth
|
|
|
|
|
unless User.current.admin? || (User.current.ec_school.present? && User.current.ec_school == @school.id)
|
|
|
|
|
def school_manager
|
|
|
|
|
unless User.current.admin? || @school.users.where(:id => User.current.id).count > 0
|
|
|
|
|
render_403
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|