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_tournament_round(url, tournament, round_num, indexes, dryrun=True): round_num = int(round_num) 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, judge_name) in scraper.processed_data: if (not aff) or (not neg): # this is a bye round because only one team was in the pairing bye_team = aff if aff else neg bye_team = tp.team_code(bye_team) enter_bye_round(bye_team, tournament, round_num, dryrun) continue aff = tp.team_code(aff) neg = tp.team_code(neg) judge_name = tp.judge(judge_name) print aff + " | " + neg + " | " + judge_name aff_team = check_team_existence_or_create(aff, tourny, dryrun) neg_team = check_team_existence_or_create(neg, tourny, dryrun) judge_obj = check_judge_existence_or_create(judge_name, dryrun) try: print aff + " v. " + neg round = Round.objects.get(aff_team=aff_team, neg_team=neg_team, tournament=tourny) print "already made round" except: print aff + " v. " + neg round_obj = Round(aff_team=aff_team, neg_team=neg_team, round_num=round_num) if not dryrun: if tourny.curr_rounds < round_num: tourny.curr_rounds = round_num tourny.save() round_obj.save() round_obj.tournament.add(tourny) round_obj.judge.add(judge_obj) print "round made"