def enter_tournament_elim_round(url, tournament, round_num, indexes, dryrun=True): tourny = Tournament.objects.get(tournament_name = tournament) scraper = PairingScraper(url, tournament) scraper.process_pairings(int(indexes[0]), int(indexes[1]), int(indexes[2])) for (aff, neg, judges) in scraper.processed_data: aff = tp.team_code(aff) neg = tp.team_code(neg) if judges: judge1_name, judge2_name, judge3_name = tp.judge(judges) aff_team = check_team_existence_or_create(aff, tourny, dryrun) neg_team = check_team_existence_or_create(neg, tourny, dryrun) if judges: judge1_obj = check_judge_existence_or_create(judge1_name, dryrun) judge2_obj = check_judge_existence_or_create(judge2_name, dryrun) judge3_obj = check_judge_existence_or_create(judge3_name, dryrun) else: judge1_name = judge2_name = judge3_name = "Ghandi" judge1_obj = Judge.objects.get(name="Ghandi") judge2_obj = Judge.objects.get(name="unknown1") judge3_obj = Judge.objects.get(name="unknown2") try: round = ElimRound.objects.get(aff_team=aff_team, neg_team=neg_team, tournament=tourny) print "already made round" except: print aff + " v. " + neg, judge1_name, judge2_name, judge3_name round_obj = ElimRound(aff_team=aff_team, neg_team=neg_team, round_num=round_num) if not dryrun: round_obj.save() round_obj.tournament.add(tourny) round_obj.judge.add(judge1_obj) round_obj.judge.add(judge2_obj) round_obj.judge.add(judge3_obj) print "round made"
def enter_individual_elim_round(tournament, association, round_num, aff_code, neg_code, j1, j2, j3, winloss, aff_name="enter_names", neg_name="enter_names", dryrun=True): try: tourny = Tournament.objects.get(tournament_name = tournament) aff = tp.team_code(aff_code) neg = tp.team_code(neg_code) if (j1 == j2) and (j2 == j3) and (j1 == j3): j1_obj = Judge.objects.get(name = "unknown") j2_obj = Judge.objects.get(name = "unknown1") j3_obj = Judge.objects.get(name = "unknown2") else: j1 = tp.judge(j1) j2 = tp.judge(j2) j3 = tp.judge(j3) j1_obj = check_judge_existence_or_create(j1, dryrun) j2_obj = check_judge_existence_or_create(j2, dryrun) j3_obj = check_judge_existence_or_create(j3, dryrun) aff_team = check_team_existence_or_create(aff, tourny, aff_name, dryrun) neg_team = check_team_existence_or_create(neg, tourny, neg_name, dryrun) try: round = ElimRound.objects.get(aff_team=aff_team, neg_team=neg_team, tournament=tourny) print "already made round" except: print aff + " v. " + neg round_obj = ElimRound(aff_team=aff_team, neg_team=neg_team, round_num=round_num) round_obj.association = association if not dryrun: if round_num >= tourny.breaks_to: print "********************************", round_num tourny.breaks_to = round_num tourny.save() round_obj.save() if winloss == "Aff": round_obj.winner = aff_team round_obj.loser = neg_team round_obj.aff_votes.add(j1_obj) round_obj.aff_votes.add(j2_obj) round_obj.aff_votes.add(j3_obj) elif winloss == "Neg": round_obj.winner = neg_team round_obj.loser = aff_team round_obj.neg_votes.add(j1_obj) round_obj.neg_votes.add(j2_obj) round_obj.neg_votes.add(j3_obj) round_obj.tournament.add(tourny) round_obj.judge.add(j1_obj) round_obj.judge.add(j2_obj) round_obj.judge.add(j3_obj) round_obj.save() print "round made" except: "there was an error"