示例#1
0
文件: views.py 项目: yesnik/podium
    def queryset(self):

        if 'year' not in self.kwargs:
            year = Contest.get_active_year()
        else:
            year = int(self.kwargs['year'])

        collections_year_list = Collection.objects.filter(contest__year=year)

        vuz_list = []
        _dict = {}
        _list = []

        for collection in collections_year_list:
            for author in collection.author.all():
                if author.vuz not in _list:
                    _list.append(author.vuz)
                    _dict['vuz'] = author.vuz
                    _dict['collection_amount'] = len(Collection.get_vuz_collections_by_year(author.vuz.vuz_url, year))
                    vuz_list.append(_dict)
                    _dict = {}

        del _list

        return vuz_list
示例#2
0
文件: views.py 项目: yesnik/podium
    def get_context_data(self, **kwargs):

        context = super(VuzYearListView, self).get_context_data(**kwargs)

        year_list = Contest.get_years()

        if 'year' in self.kwargs:
            year = int(self.kwargs['year'])

        else:
            year = Contest.get_active_year()
        context['year'] = year

        #Удаляем текущий год из списка, т.к. он уже отображается на странице
        if year in year_list:
            year_list.remove(year)

        context['year_list'] = year_list

        return context