socialforge/app/helpers/contests_helper.rb

28 lines
803 B
Ruby
Raw Normal View History

2014-04-03 22:38:18 +08:00
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
2016-12-22 10:01:37 +08:00
end