コード例 #1
0
    def test_get_season(self):

        # create two seasons
        classification = Classification(label='test mens')
        classification.save()
        competition = Competition(
            name='div 1',
            mode='l',
            classification=classification
        )
        competition.save()
        season_1 = Season(label='s1',
            start_date=datetime.date.today(),
            end_date=datetime.date.today() + datetime.timedelta(365),
            competition=competition,
            published=True
        )
        season_2 = Season(label='s2',
            start_date=datetime.date.today() + datetime.timedelta(365),
            end_date=datetime.date.today() + datetime.timedelta(730),
            competition=competition
        )
        season_1.save()
        season_2.save()

        self.assertIn(season_1,
            Season.get_current_season_by_slugs('test-mens', 'div-1'))
        self.assertNotIn(season_2,
            Season.get_current_season_by_slugs('test-mens', 'div-1'))
コード例 #2
0
ファイル: test_models.py プロジェクト: robkohajduk/roots
    def test_create_duplicate_competitions(self):
        competition1 = Competition(name="DuplicateCompetition")
        competition2 = Competition(name="DuplicateCompetition")

        with self.assertRaises(IntegrityError):
            competition1.save()
            competition2.save()
コード例 #3
0
ファイル: views.py プロジェクト: osufitchi/brackets
 def form_valid(self,form):
     self.object = form.save()
     competitor = Competitor(name="Default Name", bracket=self.object)
     seeds = xrange(self.object.maxnum)
     for person in range(self.object.maxnum):
         competitor.pk = None
         competitor.seed = person
         competitor.save()
     for i  in  range(self.object.maxnum / 2 ):
         comp = Competition(bracket=self.object,competitor_a=Competitor.objects.get(bracket=self.object,seed=seeds[2 * i]),competitor_b=Competitor.objects.get(bracket=self.object,seed=seeds[2 * i + 1]))
         comp.save()
     return super(BracketCreateView, self).form_valid(form)
コード例 #4
0
ファイル: generate_data.py プロジェクト: tufyx/amh_api
def build_competitions():
    seasons = Season.objects.all()
    for s in seasons:
        count_competitions = randint(3,6)
        levels = Level.objects.all()
        index = 0
        while index < count_competitions:
            level = levels[randint(0, levels.count() - 1)]
            name = 'S_{id}-C_{index}'.format(id=s.id, index=index)
            c = Competition(name=name, level=level, season=s)
            c.save()
            c.build_matches()
            c.build_statistics()
            index += 1
コード例 #5
0
def create_season(classification, competition, season_label, start, end):

    competition = Competition(
        name=competition,
        mode='l',
        classification=classification
    )
    competition.save()
    season = Season(label=season_label,
        start_date=start,
        end_date=end,
        competition=competition
    )
    season.save()

    return season
コード例 #6
0
ファイル: views.py プロジェクト: osufitchi/brackets
def check_bracket_round_complete(bracket):
    if Competition.objects.filter(bracket = bracket,winner=None):
        pass
    else:
        br = Bracket.objects.get(id=bracket)
        br.tourny_round += 1 
        br.save()
        compnum = Competition.objects.filter(bracket = br.id, tourny_round=br.tourny_round - 1).count()  / 2

        #obvious bug here, try to fix it at some point
        # hint: it's only a problem if more then one person is using the site at a time ~~ hey are you there?? :(
        winnerlist = Competition.objects.values_list('winner',flat=True).filter(tourney_round = br.tourney_round - 1).exclude(winner=None).order_by('id')
        players=zigzag(winnerlist)

        for player_a, player_b in players:
            comp = Competition(bracket = br, tourny_round = br.tourny_round,commit = False)
            comp.competitor_a = player_a
            comp.competitor_b = player_b
            comp.save()
コード例 #7
0
ファイル: test_models.py プロジェクト: robkohajduk/roots
 def test_create_competition_with_organizer_group(self):
     competition = Competition(name="TestCompetition",
                               organizer_group=self.group)
     competition.save()
コード例 #8
0
ファイル: test_models.py プロジェクト: robkohajduk/roots
 def test_create_simple_competition(self):
     competition = Competition(name="TestCompetition")
     competition.save()