socialforge/app/helpers/contests_helper.rb

48 lines
1.2 KiB
Ruby

module ContestsHelper
# 获取动态列表名称
def get_acts_list_type type
case type
when "work"
l(:label_homework_acts)
when "news"
l(:label_news_acts)
when "attachment"
l(:label_attachment_acts)
when "message"
l(:label_message_acts)
when "journalsForMessage"
l(:label_journalsForMessage_acts)
when "poll"
l(:label_poll_acts)
else
l(:label_all_cats)
end
end
# 判断当前用户是否为竞赛管理员
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