You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/controllers/competitions/prizes_controller.rb

29 lines
1.2 KiB

class Competitions::PrizesController < Competitions::BaseController
before_action :require_prize_user!
def show
5 years ago
self_prizes = current_competition.competition_prize_users.where(user_id: current_user.id).includes(:competition_team).order(:competition_prize_id)
5 years ago
@leader = self_prizes.any?{ |prize_user| prize_user.leader? && prize_user.competition_prize.category == 'bonus' } # 是否为队长并且有奖金奖励
if @leader
@bank_account = self_prizes.find(&:leader?).extra
@bank_account_editable = self_prizes.select(&:leader?).all?(&:pending?)
end
@self_prizes = self_prizes.select(&:certificate_exist?) # 个人证书quit
@team_prizes = self_prizes.map(&:competition_team).uniq.select(&:certificate_exists?) # 团队证书
prize_users = current_competition.competition_prize_users.where(competition_team_id: self_prizes.map(&:competition_team_id))
.includes(:competition_team, user: [:user_extension, :process_real_name_apply, :process_professional_apply])
@prize_user_map = prize_users.group_by(&:competition_team)
end
private
def require_prize_user!
return if current_competition.competition_prize_users.exists?(user: current_user)
render_forbidden
end
end