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.
26 lines
1.0 KiB
26 lines
1.0 KiB
5 years ago
|
class Competitions::PrizesController < Competitions::BaseController
|
||
|
before_action :require_prize_user!
|
||
|
|
||
|
def show
|
||
|
self_prizes = current_competition.competition_prize_users.where(user_id: current_user.id).includes(:competition_team)
|
||
|
|
||
|
@leader = self_prizes.any?(&:leader?) # 是否为队长
|
||
|
@bank_account = self_prizes.find(&:leader?).extra if @leader
|
||
|
|
||
|
@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
|