实训首页的一些优化

dev_course
jingquan huang 6 years ago
parent 3215cc4a0f
commit 6adf125450

@ -258,6 +258,8 @@ class ApplicationController < ActionController::Base
end end
def user_setup def user_setup
# reacct静态资源加载不需要走这一步
return if params[:controller] == "main"
# Find the current user # Find the current user
User.current = find_current_user User.current = find_current_user
uid_logger("user_step: " + (User.current.logged? ? "#{User.current.try(:login)} (id=#{User.current.try(:id)})" : "anonymous")) uid_logger("user_step: " + (User.current.logged? ? "#{User.current.try(:login)} (id=#{User.current.try(:id)})" : "anonymous"))

@ -1,5 +1,5 @@
class ShixunsController < ApplicationController class ShixunsController < ApplicationController
before_action :require_login, except: [:download_file, :index] before_action :require_login, except: [:download_file, :index, :menus]
# before_action :check_auth, except: [:download_file, :index] # before_action :check_auth, except: [:download_file, :index]
before_action :find_shixun, except: [:index, :new, :create, :menus, :get_recommend_shixuns, :propaedeutics, before_action :find_shixun, except: [:index, :new, :create, :menus, :get_recommend_shixuns, :propaedeutics,

@ -388,10 +388,10 @@ class User < ApplicationRecord
# 用户是否有权限查看实训 # 用户是否有权限查看实训
def shixun_permission(shixun) def shixun_permission(shixun)
# 性能优化:先处理不需要权限的实训(已发布并且没有单位权限限制的实训) # 性能优化:先处理不需要权限的实训(已发布并且没有单位权限限制的实训)
return true if manager_of_shixun?(shixun) # 实训管理员
return false if shixun.status != 2 || shixun.hidden # 隐藏或者未发布的实训false return false if shixun.status != 2 || shixun.hidden # 隐藏或者未发布的实训false
return true if shixun.use_scope == 0 # 对所有学校公开 return true if shixun.use_scope == 0 # 对所有学校公开
return true if shixun.use_scope == 1 && shixun.shixun_schools.exists?(school_id: school_id) # 对部分高校公开 return true if shixun.use_scope == 1 && (manager_of_shixun?(shixun) || shixun.shixun_schools.exists?(school_id: school_id)) # 对部分高校公开
# return true if manager_of_shixun?(shixun) # 实训管理员
return false return false
end end

Loading…
Cancel
Save