实训首页权限控制错误

dev_forum
daiao 5 years ago
parent 8a5da06e8e
commit ffc36c5cf2

@ -82,8 +82,8 @@ class SubjectsController < ApplicationController
@is_creator = current_user.creator_of_subject?(@subject) @is_creator = current_user.creator_of_subject?(@subject)
# 合作团队 # 合作团队
@members = @subject.subject_members.includes(:user) @members = @subject.subject_members.includes(:user)
shixun_ids = @subject.shixuns.published.pluck(:id) @shixuns = @subject.shixuns.published.pluck(:id)
challenge_ids = Challenge.where(shixun_id: shixun_ids).pluck(:id) challenge_ids = Challenge.where(shixun_id: @shixuns).pluck(:id)
# 实训路径中的所有实训标签 # 实训路径中的所有实训标签
@tags = ChallengeTag.where(challenge_id: challenge_ids).pluck(:name).uniq @tags = ChallengeTag.where(challenge_id: challenge_ids).pluck(:name).uniq
# 用户获取的实训标签 # 用户获取的实训标签

@ -1,10 +1,10 @@
module SubjectsHelper module SubjectsHelper
# 实训路径的发布状态 # 实训路径的发布状态
def publish_status subject, is_manager, user def publish_status subject, is_manager, user, shixuns
status = -1 status = -1
if is_manager if is_manager
status = 0 if subject.status == 0 && subject.shixuns_count > 0 status = 0 if subject.status == 0 && shixuns.count > 0
status = 1 if subject.status == 1 status = 1 if subject.status == 1
status = 2 if subject.status == 2 && user.admin? status = 2 if subject.status == 2 && user.admin?
end end

@ -6,7 +6,7 @@ json.subject_score @subject.all_score
json.member_count @subject.member_count json.member_count @subject.member_count
json.allow_delete @is_creator && (@subject.status != 2 || @user.admin?) json.allow_delete @is_creator && (@subject.status != 2 || @user.admin?)
json.publish_status publish_status(@subject, @is_creator, @user) json.publish_status publish_status(@subject, @is_creator, @user, @shixuns)
json.allow_statistics @user.manager_of_subject?(@subject) json.allow_statistics @user.manager_of_subject?(@subject)
json.allow_send @user.logged? json.allow_send @user.logged?
json.allow_visit @user.manager_of_subject?(@subject) || @user.admin? || @subject.status > 1 json.allow_visit @user.manager_of_subject?(@subject) || @user.admin? || @subject.status > 1

Loading…
Cancel
Save