コード例 #1
0
ファイル: graphics.py プロジェクト: asbjornu/demozoo
def index(request):
    queryset = Production.objects.filter(supertype='graphics')

    order = request.GET.get('order', 'date')
    asc = request.GET.get('dir', 'desc') == 'asc'

    queryset = apply_order(queryset, order, asc)

    form = GraphicsIndexFilterForm(request.GET)

    if form.is_valid():
        if form.cleaned_data['platform']:
            queryset = queryset.filter(platforms=form.cleaned_data['platform'])
        if form.cleaned_data['production_type']:
            prod_types = ProductionType.get_tree(
                form.cleaned_data['production_type'])
            queryset = queryset.filter(types__in=prod_types)

    queryset = queryset.prefetch_related('author_nicks__releaser',
                                         'author_affiliation_nicks__releaser',
                                         'platforms', 'types')

    production_page = get_page(queryset, request.GET.get('page', '1'))

    return render(
        request, 'graphics/index.html', {
            'order': order,
            'production_page': production_page,
            'menu_section': "graphics",
            'asc': asc,
            'form': form,
        })
コード例 #2
0
ファイル: graphics.py プロジェクト: alexanderk23/demozoo
def index(request):
	queryset = Production.objects.filter(supertype='graphics')

	order = request.GET.get('order', 'date')
	asc = request.GET.get('dir', 'desc') == 'asc'

	queryset = apply_order(queryset, order, asc)

	form = GraphicsIndexFilterForm(request.GET)

	if form.is_valid():
		if form.cleaned_data['platform']:
			queryset = queryset.filter(platforms=form.cleaned_data['platform'])
		if form.cleaned_data['production_type']:
			prod_types = ProductionType.get_tree(form.cleaned_data['production_type'])
			queryset = queryset.filter(types__in=prod_types)

	queryset = queryset.select_related('default_screenshot').prefetch_related('author_nicks__releaser', 'author_affiliation_nicks__releaser', 'platforms', 'types')

	production_page = get_page(
		queryset,
		request.GET.get('page', '1'))

	return render(request, 'graphics/index.html', {
		'order': order,
		'production_page': production_page,
		'menu_section': "graphics",
		'asc': asc,
		'form': form,
	})