Exemple #1
0
    def get_context_data(self, **kwargs):
        context = super(CommitteeSeasonView, self).get_context_data(**kwargs)

        # If we're viewing this season's committee we may not have a season_slug keyword arg.
        season = get_season_from_kwargs(kwargs)

        all_members = CommitteeMembership.objects.select_related('position', 'member', 'season').by_season(season)

        context['general_committee'] = [m for m in all_members if m.position.gender == TeamGender.Mixed]
        ladies_committee = [m for m in all_members if m.position.gender == TeamGender.Ladies]
        mens_committee = [m for m in all_members if m.position.gender == TeamGender.Mens]

        context['ladies_captains'] = [{
            'name': "Ladies 1st team",
            'captain': next((m for m in ladies_committee if m.position.name == "Ladies' 1st XI Captain"), None),
            'vice_captain': next((m for m in ladies_committee if m.position.name == "Ladies' 1st XI Vice-Captain"), None)
        },{
            'name': "Ladies 2nd team",
            'captain': next((m for m in ladies_committee if m.position.name == "Ladies' 2nd XI Captain"), None),
            'vice_captain': next((m for m in ladies_committee if m.position.name == "Ladies' 2nd XI Vice-Captain"), None)
        },{
            'name': "Ladies 3rd team",
            'captain': next((m for m in ladies_committee if m.position.name == "Ladies' 3rd XI Captain"), None),
            'vice_captain': next((m for m in ladies_committee if m.position.name == "Ladies' 3rd XI Vice-Captain"), None)
        },{
            'name': "Ladies 4th team",
            'captain': next((m for m in ladies_committee if m.position.name == "Ladies' 4th XI Captain"), None),
            'vice_captain': next((m for m in ladies_committee if m.position.name == "Ladies' 4th XI Vice-Captain"), None)
        }]


        context['mens_captains'] = [{
            'name': "Mens 1st team",
            'captain': next((m for m in mens_committee if m.position.name == "Men's 1st XI Captain"), None),
            'vice_captain': next((m for m in mens_committee if m.position.name == "Men's 1st XI Vice-Captain"), None)
        },{
            'name': "Mens 2nd team",
            'captain': next((m for m in mens_committee if m.position.name == "Men's 2nd XI Captain"), None),
            'vice_captain': next((m for m in mens_committee if m.position.name == "Men's 2nd XI Vice-Captain"), None)
        },{
            'name': "Mens 3rd team",
            'captain': next((m for m in mens_committee if m.position.name == "Men's 3rd XI Captain"), None),
            'vice_captain': next((m for m in mens_committee if m.position.name == "Men's 3rd XI Vice-Captain"), None)
        },{
            'name': "Mens 4th team",
            'captain': next((m for m in mens_committee if m.position.name == "Men's 4th XI Captain"), None),
            'vice_captain': next((m for m in mens_committee if m.position.name == "Men's 4th XI Vice-Captain"), None)
        },{
            'name': "Mens 5th team",
            'captain': next((m for m in mens_committee if m.position.name == "Men's 5th XI Captain"), None),
            'vice_captain': next((m for m in mens_committee if m.position.name == "Men's 5th XI Vice-Captain"), None)
        }]

        add_season_selector(context, season, Season.objects.reversed())
        return context
Exemple #2
0
    def get_context_data(self, **kwargs):
        """ Gets the context data for the view.

            In addition to the 'goalking_list' item, the following are also added to the context:
            - season:               the season these stats applies to
            - season_list:          a list of all seasons
        """
        context = super(AccidentalTouristSeasonView, self).get_context_data(**kwargs)
        season = get_season_from_kwargs(kwargs)

        context['goalking_list'] = self.get_goalking_list(season)

        add_season_selector(context, season, Season.objects.reversed())

        return context
Exemple #3
0
    def get_context_data(self, **kwargs):
        """ Gets the context data for the view.

            In addition to the 'team_list' item, the following are also added to the context:
            - season:               the season these stats applies to
            - season_list:          a list of all seasons
            - is_current_season:    True if season == Season.current()
        """
        context = super(SouthernersSeasonView, self).get_context_data(**kwargs)
        season = get_season_from_kwargs(kwargs)

        context['team_list'] = self.get_southerners_list(season)

        add_season_selector(context, season, Season.objects.reversed())

        return context
Exemple #4
0
    def get_context_data(self, **kwargs):
        """ Gets the context data for the view.

            In addition to the 'team_list' item, the following are also added to the context:
            - season:               the season these stats applies to
            - season_slug_list:     a list of all seasons
            - is_current_season:    True if season == Season.current()
        """
        context = super(SouthernersSeasonView, self).get_context_data(**kwargs)
        season = get_season_from_kwargs(kwargs)

        context['team_list'] = self.get_southerners_list(season)

        season_slug_list = list(Southerner.objects.order_by(
            '-season').values_list('season__slug', flat=True).distinct())

        add_season_selector(context, season, season_slug_list)

        return context
Exemple #5
0
    def get_context_data(self, **kwargs):
        context = super(CommitteeSeasonView, self).get_context_data(**kwargs)

        # If we're viewing this season's committee we may not have a season_slug keyword arg.
        season = get_season_from_kwargs(kwargs)

        all_members = CommitteeMembership.objects.select_related(
            'position', 'member', 'season').filter(season=season).order_by('position__index')

        context['general_committee'] = [
            m for m in all_members if m.position.gender == TeamGender.Mixed]
        ladies_committee = [
            m for m in all_members if m.position.gender == TeamGender.Ladies]
        mens_committee = [
            m for m in all_members if m.position.gender == TeamGender.Mens]

        ladies_team_names = list(
            ClubTeam.objects.ladies().values_list('long_name', flat=True))
        mens_team_names = list(
            ClubTeam.objects.mens().values_list('long_name', flat=True))

        context['mens_captains'] = self.get_captains(
            mens_committee, mens_team_names)

        context['ladies_captains'] = self.get_captains(
            ladies_committee, ladies_team_names)

        context['mixed_captains'] = {
            'name': "Mixed XI",
            'captain': next((m for m in mens_committee if m.position.name == "Men's Mixed XI Co-Captain"), None),
            'vice_captain': next((m for m in ladies_committee if m.position.name == "Ladies' Mixed XI Co-Captain"), None)
        }

        season_slug_list = list(CommitteeMembership.objects.order_by(
            '-season').values_list('season__slug', flat=True).distinct())

        add_season_selector(
            context, season, season_slug_list)

        return context
Exemple #6
0
    def get_context_data(self, **kwargs):
        """ Gets the context data for the view.

            In addition to the 'goalking_list' item, the following are also added to the context:
            - season:               the season these stats applies to
            - season_list:          a list of all seasons
        """
        context = super(AccidentalTouristSeasonView,
                        self).get_context_data(**kwargs)
        season = get_season_from_kwargs(kwargs)

        context['goalking_list'] = self.get_goalking_list(season)

        context['max_miles'] = context['goalking_list'][0].total_miles

        season_slug_list = list(
            GoalKing.objects.order_by('-season').values_list(
                'season__slug', flat=True).distinct())

        add_season_selector(context, season, season_slug_list)

        return context
Exemple #7
0
    def get_context_data(self, **kwargs):
        context = super(MatchesBySeasonView, self).get_context_data(**kwargs)
        season = get_season_from_kwargs(kwargs)

        match_qs = Match.objects.select_related('our_team', 'opp_team__club', 'venue',
                                                'division__league', 'cup', 'season')
        match_qs = match_qs.filter(season=season)
        match_qs = match_qs.defer('report_body', 'pre_match_hype')
        match_qs = match_qs.order_by('date', 'time')

        # Group matches by calendar year (e.g. Sept-Dec in one group, Jan-April in the other)
        year1 = [m for m in match_qs if m.date.year == season.start.year]
        year2 = [m for m in match_qs if m.date.year == season.end.year]

        matches_by_year = {
            season.start.year: self.group_by_month(year1),
            season.end.year: self.group_by_month(year2)
        }

        context['matches_by_year'] = matches_by_year

        add_season_selector(context, season, Season.objects.reversed())

        return context