def _points_leader(self, team=None): """Return the point leader.""" if self.round == None: round_name = "Round 1" else: round_name = self.round.name if self.award_to == "individual_overall": return player_mgr.points_leader(round_name=round_name) elif self.award_to == "team_group": if team: leaders = team.group.team_points_leaders(num_results=1, round_name=round_name) if leaders: return leaders[0] return None elif self.award_to == "team_overall": return team_mgr.team_points_leader(round_name=round_name) elif self.award_to == "individual_team": if team: leaders = team.points_leaders(num_results=1, round_name=round_name) if leaders: return leaders[0] return None elif self.award_to == "group_overall": return score_mgr.group_points_leader() raise Exception("'%s' is not implemented yet." % self.award_to)
def supply(request, page_name): """Supply view_objects contents, which are the player name, team and points.""" """Supply the view_objects content.""" _ = request group_winner = score_mgr.group_points_leader() return { 'group_winner':group_winner}
def group_points_leader(round_name=None, place=1): """Returns the team points leader (the place) across all groups, as a Team object.""" if not round_name: round_name = challenge_mgr.get_round_name() group_id = score_mgr.group_points_leader(round_name=round_name, place=place) if group_id: return Group.objects.get(id=group_id) else: groups = Group.objects.all() if len(groups) >= place: return groups[place - 1] else: return None
def group_points_leader(round_name=None): """Returns the team points leader (the first place) across all groups, as a Team object.""" if not round_name: round_name = challenge_mgr.get_round_name() group_id = score_mgr.group_points_leader(round_name=round_name) if group_id: return Group.objects.get(id=group_id) else: groups = Group.objects.all() if groups: return groups[0] else: return None
def num_awarded(self, team=None): """Returns the number of prizes that will be awarded for this prize.""" _ = team if self.award_to in ("individual_overall", "team_overall", "group"): # For overall prizes, it is only possible to award one. return 1 elif self.award_to in ("team_group", "individual_group"): # For dorm prizes, this is just the number of groups. return Group.objects.count() elif self.award_to == "individual_team": # This is awarded to each team. return Team.objects.count() elif self.award_to == "group_overall": # This is awarded to each group. return score_mgr.group_awarded(score_mgr.group_points_leader()) raise Exception("Unknown award_to value '%s'" % self.award_to)