def supply(request, page_name): """Supply the view_objects content for this widget, which is all the scoreboard data.""" user = request.user team = user.get_profile().team num_results = 10 if page_name != "status" else None round_standings = {} current_round = challenge_mgr.get_round_name() today = datetime.datetime.today() rounds = challenge_mgr.get_all_round_info()["rounds"] for key in rounds.keys(): # 1. always display current round # 2. if not future round # a. display the round with the "display_scoreboard" flag # b. display in the status page if rounds[key]["start"] <= today and \ (rounds[key]["display_scoreboard"] or page_name == "status"): round_standings[key] = { "group_standings": team_mgr.group_points_leaders(num_results, key), "team_standings": team_mgr.team_points_leaders(num_results, key), "profile_standings": player_mgr.points_leaders(num_results, key), "group_participation": team_mgr.group_active_participation(num_results, key) if \ page_name == "status" else None, "team_participation": team_mgr.team_active_participation(num_results, key) if \ page_name == "status" else None, "user_team_standings": team.points_leaders(num_results, key) if \ team and page_name != "status" else None, } # add an overall scoreboard round_standings["Overall"] = { "group_standings": team_mgr.group_points_leaders(num_results, "Overall"), "team_standings": team_mgr.team_points_leaders(num_results, "Overall"), "profile_standings": player_mgr.points_leaders(num_results, "Overall"), "group_participation": team_mgr.group_active_participation(num_results, "Overall") if\ page_name == "status" else None, "team_participation": team_mgr.team_active_participation(num_results, "Overall") if \ page_name == "status" else None, } count = len(rounds) return { "profile": user.get_profile(), "team": team, "current_round": current_round, "round_standings": round_standings, "no_carousel": page_name == "status", "range": count, "user": user, }
def supply(request, page_name): """Supply the view_objects content for this widget, which is all the scoreboard data.""" user = request.user team = user.get_profile().team num_results = 10 if page_name != "status" else None round_standings = {} current_round = challenge_mgr.get_round_name() rounds = challenge_mgr.get_all_round_info()["rounds"] for key in rounds.keys(): if key == current_round or page_name == "status": round_standings[key] = { "team_standings": team_mgr.team_points_leaders(num_results, key), "profile_standings": player_mgr.points_leaders(num_results, key), "team_participation": team_mgr.team_active_participation(num_results, key) if \ page_name == "status" else None, "user_team_standings": team.points_leaders(num_results, key) if \ team and page_name != "status" else None, } count = len(rounds) return { "profile": user.get_profile(), "team": team, "current_round": current_round, "round_standings": round_standings, "no_carousel": page_name == "status", "range": count, "user": user, }
def prize_summary(request, round_name): """display summary of the winners.""" round_name = round_name.replace('-', ' ').capitalize() individual_team_prize = Prize.objects.filter(round=RoundSetting.objects.get(name=round_name), competition_type="points", award_to="individual_team") teams = Team.objects.all() if individual_team_prize: individual_team_prize = individual_team_prize[0] for team in teams: team.leader = individual_team_prize.leader(team=team) team_energy_goal_prize = Prize.objects.filter(round=RoundSetting.objects.get(name=round_name), competition_type="energy_goal", award_to="team_overall") energy_team_ra = None if team_energy_goal_prize: team_energy_goal_prize = team_energy_goal_prize[0] energy_team_ra = Profile.objects.filter(team__name=team_energy_goal_prize.leader(), is_ra=True) team_points_prize = Prize.objects.filter(round=RoundSetting.objects.get(name=round_name), competition_type="points", award_to="team_overall") point_team_ra = None if team_points_prize: team_points_prize = team_points_prize[0] point_team_ra = Profile.objects.filter(team__name=team_points_prize.leader(), is_ra=True) points_leader = score_mgr.player_points_leaders(round_name=round_name) if points_leader: points_leader = points_leader[0] return render_to_response("view_prizes/summary.html", { "team_energy_goal_prize": team_energy_goal_prize, "energy_team_ra": energy_team_ra, "goal": resource_goal.resource_goal_ranks("energy", round_name)[0]["completions"], "team_points_prize": team_points_prize, "team_point": team_mgr.team_points_leaders(round_name=round_name)[0]["points"], "team_participation": team_mgr.team_active_participation( round_name=round_name)[0].active_participation, "point_team_ra": point_team_ra, "individual_overall_prize": Prize.objects.filter( round=RoundSetting.objects.get(name=round_name), competition_type="points", award_to="individual_overall")[0], "individual_point": points_leader["points"] if points_leader else None, "individual_team_prize": individual_team_prize, "teams": teams }, context_instance=RequestContext(request))
def prize_summary(request, round_name): """display summary of the winners.""" round_name = round_name.replace('-', ' ').capitalize() individual_team_prize = Prize.objects.filter( round=RoundSetting.objects.get(name=round_name), competition_type="points", award_to="individual_team") teams = Team.objects.all() if individual_team_prize: individual_team_prize = individual_team_prize[0] for team in teams: team.leader = individual_team_prize.leader(team=team) team_energy_goal_prize = Prize.objects.filter( round=RoundSetting.objects.get(name=round_name), competition_type="energy_goal", award_to="team_overall") energy_team_ra = None if team_energy_goal_prize: team_energy_goal_prize = team_energy_goal_prize[0] energy_team_ra = Profile.objects.filter( team__name=team_energy_goal_prize.leader(), is_ra=True) team_points_prize = Prize.objects.filter( round=RoundSetting.objects.get(name=round_name), competition_type="points", award_to="team_overall") point_team_ra = None if team_points_prize: team_points_prize = team_points_prize[0] point_team_ra = Profile.objects.filter( team__name=team_points_prize.leader(), is_ra=True) points_leader = score_mgr.player_points_leaders(round_name=round_name) if points_leader: points_leader = points_leader[0] return render_to_response("view_prizes/summary.html", { "team_energy_goal_prize": team_energy_goal_prize, "energy_team_ra": energy_team_ra, "goal": resource_goal.resource_goal_ranks("energy", round_name)[0]["completions"], "team_points_prize": team_points_prize, "team_point": team_mgr.team_points_leaders(round_name=round_name)[0]["points"], "team_participation": team_mgr.team_active_participation( round_name=round_name)[0].active_participation, "point_team_ra": point_team_ra, "individual_overall_prize": Prize.objects.filter(round=RoundSetting.objects.get(name=round_name), competition_type="points", award_to="individual_overall")[0], "individual_point": points_leader["points"] if points_leader else None, "individual_team_prize": individual_team_prize, "teams": teams }, context_instance=RequestContext(request))