28 lines
803 B
Ruby
28 lines
803 B
Ruby
module ContestsHelper
|
|
|
|
# 判断当前用户是否为竞赛管理员
|
|
def is_contest_manager?(user_id, contest_id)
|
|
@result = false
|
|
mem = ContestMember.where("user_id = ? and contest_id = ?",user_id, contest_id)
|
|
unless mem.blank?
|
|
@result = mem.first.roles.to_s.include?("ContestManager") ? true : false
|
|
end
|
|
return @result
|
|
end
|
|
|
|
# 获取竞赛的管理人员
|
|
def contest_managers contest
|
|
contest.contest_members.select{|cm| cm.roles.to_s.include?("ContestManager")}
|
|
end
|
|
|
|
# 获取竞赛的评委人员
|
|
def contest_judges contest
|
|
contest.contest_members.select{|cm| cm.roles.to_s.include?("Judge")}
|
|
end
|
|
|
|
# 获取竞赛的参赛人员
|
|
def contest_contestants contest
|
|
contest.contest_members.select{|cm| cm.roles.to_s.include?("Contestant")}
|
|
end
|
|
end
|