|
|
|
@ -390,13 +390,17 @@ class User < ApplicationRecord
|
|
|
|
|
# 2、实训隐藏了只有管理员、实训合作者能看到
|
|
|
|
|
# 3、如果有限制学校范围,则学校的用户、管理员、实训合作者能看到
|
|
|
|
|
def shixun_permission(shixun)
|
|
|
|
|
case status
|
|
|
|
|
case shixun.status
|
|
|
|
|
when -1 # 软删除只有管理员能访问
|
|
|
|
|
admin?
|
|
|
|
|
when 0, 1, 3 # 申请发布或者已关闭的实训,只有实训管理员可以访问
|
|
|
|
|
manager_of_shixun?(shixun)
|
|
|
|
|
when 2
|
|
|
|
|
shixun.use_scope == 0 || manager_of_shixun?(shixun) || shixun.shixun_schools.exists?(school_id: school_id)
|
|
|
|
|
if shixun.hidden
|
|
|
|
|
manager_of_shixun?(shixun)
|
|
|
|
|
else
|
|
|
|
|
shixun.use_scope == 0 || manager_of_shixun?(shixun) || shixun.shixun_schools.exists?(school_id: school_id)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|