コード例 #1
0
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,
    }
コード例 #2
0
ファイル: participation.py プロジェクト: socialray/makahiki
def award_participation():
    """award the participation rate for all team."""

    if not challenge_mgr.is_game_enabled("Participation Game"):
        return

    p_setting, _ = ParticipationSetting.objects.get_or_create(pk=1)

    current_round = challenge_mgr.get_round_name()

    for team in team_mgr.team_active_participation(round_name=current_round):
        team_participation, _ = TeamParticipation.objects.get_or_create(
            team=team, round_name=current_round)

        # check if the participation rate change
        if team_participation.participation != team.active_participation:
            # save the new participation rate

            if team.active_participation == 100:
                if team_participation.awarded_percent != "100":
                    team_participation.awarded_percent = "100"
                    team_mgr.award_member_points(team,
                                                 p_setting.points_100_percent,
                                                 "Team 100% participation")
            elif team.active_participation >= 75:
                if team_participation.awarded_percent != "75":
                    team_participation.awarded_percent = "75"
                    team_mgr.award_member_points(team,
                                                 p_setting.points_75_percent,
                                                 "Team 75% participation")
            elif team.active_participation >= 50:
                if not team_participation.awarded_percent:
                    team_participation.awarded_percent = "50"
                    team_mgr.award_member_points(team,
                                                 p_setting.points_50_percent,
                                                 "Team 50% participation")

            team_participation.participation = team.active_participation
            team_participation.save()

    # store the overall participation rate
    for team in team_mgr.team_active_participation(round_name="Overall"):
        team_participation, _ = TeamParticipation.objects.get_or_create(
            team=team, round_name="Overall")
        # check if the participation rate change
        if team_participation.participation != team.active_participation:
            # save the new participation rate
            team_participation.participation = team.active_participation
            team_participation.save()
コード例 #3
0
def award_participation():
    """award the participation rate for all team."""

    if not challenge_mgr.is_game_enabled("Participation Game"):
        return

    p_setting, _ = ParticipationSetting.objects.get_or_create(pk=1)

    current_round = challenge_mgr.get_round_name()

    for team in team_mgr.team_active_participation(round_name=current_round):
        team_participation, _ = TeamParticipation.objects.get_or_create(
            team=team, round_name=current_round)

        # check if the participation rate change
        if team_participation.participation != team.active_participation:
            # save the new participation rate

            if team.active_participation == 100:
                if team_participation.awarded_percent != "100":
                    team_participation.awarded_percent = "100"
                    team_mgr.award_member_points(team,
                                             p_setting.points_100_percent,
                                             "Team 100% participation")
            elif team.active_participation >= 75:
                if team_participation.awarded_percent != "75":
                    team_participation.awarded_percent = "75"
                    team_mgr.award_member_points(team,
                                             p_setting.points_75_percent,
                                             "Team 75% participation")
            elif team.active_participation >= 50:
                if not team_participation.awarded_percent:
                    team_participation.awarded_percent = "50"
                    team_mgr.award_member_points(team,
                                             p_setting.points_50_percent,
                                             "Team 50% participation")

            team_participation.participation = team.active_participation
            team_participation.save()

    # store the overall participation rate
    for team in team_mgr.team_active_participation(round_name="Overall"):
        team_participation, _ = TeamParticipation.objects.get_or_create(
            team=team, round_name="Overall")
        # check if the participation rate change
        if team_participation.participation != team.active_participation:
            # save the new participation rate
            team_participation.participation = team.active_participation
            team_participation.save()
コード例 #4
0
def award_participation():
    """award the participation rate for all team."""
    p_setting, _ = ParticipationSetting.objects.get_or_create(pk=1)

    for team in team_mgr.team_active_participation():
        team_participation, _ = TeamParticipation.objects.get_or_create(team=team)

        # check if the participation rate change
        if team_participation.participation != team.active_participation:
            # save the new participation rate
            team_participation.participation = team.active_participation
            team_participation.save()
            cache_mgr.delete("team_participation")

            if team.active_participation == 100:
                team_mgr.award_member_points(team,
                                             p_setting.points_100_percent,
                                             "Team 100% participation")
            elif team.active_participation >= 75:
                team_mgr.award_member_points(team,
                                             p_setting.points_75_percent,
                                             "Team 75% participation")
            elif team.active_participation >= 50:
                team_mgr.award_member_points(team,
                                             p_setting.points_50_percent,
                                             "Team 50% participation")
コード例 #5
0
ファイル: views.py プロジェクト: gregorylburgess/makahiki
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,
    }
コード例 #6
0
ファイル: views.py プロジェクト: csdl/makahiki
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))
コード例 #7
0
ファイル: views.py プロジェクト: pavelpromin/makahiki
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))