コード例 #1
0
ファイル: matchup_logic.py プロジェクト: taddeimania/tfb
def copy_roster(team):
    """ Copies roster from previous week
    """
    next_week = logic.getweek() + 1
    roster_to_copy = player_models.Roster.objects.filter(week=logic.getweek(), team=team)
    for player in roster_to_copy:
        R = player_models.Roster(week=next_week, team=team, player=player.player)
        R.save()
コード例 #2
0
ファイル: views.py プロジェクト: taddeimania/tfb
    def get_context_data(self, **kwargs):
        user = self.request.user
        week = logic.getweek()
        matchup_id = kwargs.get('matchup_id')
        if matchup_id:
            matchup = Matchup.objects.get(pk=matchup_id)
        else:
            try:
                matchup = Matchup.objects.get(
                    Q(team_one__owner=user.userprofile, week=week) |
                    Q(team_two__owner=user.userprofile, week=week)
                )
            except Matchup.DoesNotExist:
                return HttpResponseRedirect("")

        team_data = matchup_logic.get_team_data(matchup, week)

        try:
            allmatchups = Matchup.objects.filter(week=matchup.week, league=matchup.league)
        except Matchup.DoesNotExist:
            pass

        return {
            'matchup': matchup,
            'team_one': team_data['team_one']['team'],
            'team_two': team_data['team_two']['team'],
            't1pts': team_data['team_one']['points'],
            't2pts': team_data['team_two']['points'],
            'team_one_roster': team_data['team_one']['roster'],
            'team_two_roster': team_data['team_two']['roster'],
            'allmatchups': allmatchups
        }
コード例 #3
0
ファイル: matchup_logic.py プロジェクト: taddeimania/tfb
def recalculate_weekly_matchups():
    week = logic.getweek()
    MU = matchup_models.Matchup.objects.filter(week=week)
    for matchup in MU:
        t1 = player_models.Team.objects.get(pk=matchup.team_one.id)
        t2 = player_models.Team.objects.get(pk=matchup.team_two.id)
        t1pts = t1.calc_week_points()
        t2pts = t2.calc_week_points()

        matchup.team_one_points = t1pts
        matchup.team_two_points = t2pts
        matchup.save()
コード例 #4
0
ファイル: views.py プロジェクト: taddeimania/tfb
    def post(self, *args, **kwargs):
        #drop roster for current week
        week = logic.getweek()
        team = player_models.Team.objects.get(owner=self.request.user.userprofile)
        roster_list = player_models.Roster.objects.filter(week=week, team=team)
        if week > 0 < 7:
            free_agent = player_models.UserProfile.objects.get(username="******")
            self.cleanse_roster(roster_list)
            team.owner = free_agent
            team.save()
            self.deactivate_team()
        elif not week:
            self.cleanse_roster(roster_list)
            team.delete()
            self.deactivate_team()
        else:
            pass

        return HttpResponseRedirect('/')