添加成员权限判断问题

dev_oauth
daiao 6 years ago
parent df5e9280ef
commit d534d8016b

@ -81,6 +81,7 @@ class SubjectsController < ApplicationController
def show
@user = current_user
@is_creator = current_user.creator_of_subject?(@subject)
@is_manager = @user.manager_of_subject?(@subject)
# 合作团队
@members = @subject.subject_members.includes(:user)
@shixuns = @subject.shixuns.published.pluck(:id)

@ -263,9 +263,9 @@ class User < ApplicationRecord
course&.course_members.exists?(user_id: id)
end
# 实训路径管理员创建者或admin
# 实训路径管理员
def creator_of_subject?(subject)
subject.user_id == id || admin?
subject.user_id == id
end
# 实训路径合作者、admin

@ -5,12 +5,12 @@ json.challenges_count @subject.subject_challenge_count
json.subject_score @subject.all_score
json.member_count @subject.member_count
json.allow_delete @is_creator && (@subject.status != 2 || @user.admin?)
json.allow_delete (@subject.status != 2 && @is_creator) || @user.admin?
json.publish_status publish_status(@subject, @is_creator, @user, @shixuns)
json.allow_statistics @user.manager_of_subject?(@subject)
json.allow_statistics @is_manager
json.allow_send @user.logged?
json.allow_visit @user.manager_of_subject?(@subject) || @user.admin? || @subject.status > 1
json.allow_add_member @user.manager_of_subject?(@subject)
json.allow_visit @subject.status > 1 || @is_manager
json.allow_add_member @is_manager
json.members @members do |member|
json.partial! 'subject_member', locals: { user: member.user }

Loading…
Cancel
Save