Exemple #1
0
def ready_to_pair(round_to_check):
    """
    Check if we can pair a round using basic heuristics 
    In particular:
        1) We need enough N/2 judges that are *checked in*
        2) Do we have N/2 rooms
        3) We need all rounds to be entered from the previous round
    """
    if CheckIn.objects.filter(round_number=round_to_check).count(
    ) < Team.objects.filter(checked_in=True).count() / 2:
        raise errors.NotEnoughJudgesError()
    elif Room.objects.all().count() < Team.objects.filter(
            checked_in=True).count() / 2:
        raise errors.NotEnoughRoomsError()
    elif round_to_check != 1 and RoundStats.objects.all().count(
    ) < Round.objects.filter(round_number=round_to_check - 1).count() * 4:
        raise errors.PrevRoundNotEnteredError()
    else:
        prev_rounds = Round.objects.filter(round_number=round_to_check - 1)
        for r in prev_rounds:
            if r.victor == 0:
                raise errors.PrevRoundNotEnteredError()

    return True
Exemple #2
0
def have_properly_entered_data(round_to_check):
    last_round = round_to_check - 1
    prev_rounds = Round.objects.filter(round_number=last_round)
    for prev_round in prev_rounds:
        # There should be a result
        if prev_round.victor == Round.NONE:
            raise errors.PrevRoundNotEnteredError()
        # Both teams should not have byes or noshows
        gov_team, opp_team = prev_round.gov_team, prev_round.opp_team
        for team in gov_team, opp_team:
            had_bye = Bye.objects.filter(bye_team=team,
                                         round_number=last_round)
            had_noshow = NoShow.objects.filter(no_show_team=team,
                                               round_number=last_round)
            if had_bye:
                raise errors.ByeAssignmentError(
                    "{0} both had a bye and debated last round".format(team))
            if had_noshow:
                raise errors.NoShowAssignmentError(
                    "{0} both debated and had a no show".format(team))