示例#1
0
def enter_bye_round(team_code, tournament, round_num, dryrun=True):
  tourny = Tournament.objects.get(tournament_name = tournament)
  team = check_team_existence_or_create(team_code, tourny, "enter_names", dryrun)
  bye_team = Team.objects.get(team_code = "BYE")
  judge = Judge.objects.get(name = "Ghandi")
  round_obj = Round(aff_team = team, neg_team = bye_team, round_num = round_num, winner = team)
  if not dryrun:
    round_obj.winner = team
    round_obj.save()
    round_obj.tournament.add(tourny)
    round_obj.judge.add(judge)
    return round_obj
  else:
    print "success creating bye for %s in round %d" % (team_code, round_num)
示例#2
0
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"
示例#3
0
def enter_individual_round(tournament, association, round_num, aff_code, neg_code, judge_name, winloss, aff_name="enter_names", neg_name="enter_names", dryrun=True):
  global count_failed
  try:
    tourny = Tournament.objects.get(tournament_name = tournament)
    aff = tp.team_code(aff_code)
    neg = tp.team_code(neg_code)
    judge_name = tp.judge(judge_name)
    # print aff + " | " + neg + " | " + judge_name
    aff_team = check_team_existence_or_create(aff, tourny, aff_name,"enter_names", dryrun)
    neg_team = check_team_existence_or_create(neg, tourny, neg_name, "enter_names", 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)
      round_obj.association = association
      if winloss == "Aff":
        round_obj.winner = aff_team
        round_obj.loser = neg_team
      elif winloss == "Neg":
        round_obj.winner = neg_team
        round_obj.loser = aff_team
      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"
  except:
    count_failed += 1
    print count_failed, tournament, association, round_num, aff_code, neg_code, judge_name, winloss
    print count_failed, type(tournament), type(association), type(round_num), type(aff_code), type(neg_code), type(judge_name), type(winloss)
示例#4
0
def round_setup():
    for round_num in range(1, ROUNDS + 1):
        r = Round(round=round_num)
        if round_num == 1:
            r.status = 'O'
        r.save()
示例#5
0
文件: helpers.py 项目: MMX13/tipping
def round_setup():
    for round_num in range(1, ROUNDS+1):
        r = Round(round=round_num)
        if round_num==1:
            r.status='O'
        r.save()