@view(path=r'^themes/?$')
def index(request):
    order = request.GET.get('order', '')
    if not order in ['downloads', 'date']:
        order = 'downloads'

    nameFilter = request.GET.get('filter', '')
    try:
        page = int(request.GET.get('page', '1'))
    except __HOLE__:
        page = 1

    themes, page, pagesCount = get_page(order, nameFilter, page - 1)

    return render(request, 'themes/index.html', {
        'themes': themes,
        'order': order,
        'filter': nameFilter,
        'page': page + 1,
        'pages': range(1, pagesCount + 1),
        'nextPage': page + 2 if page < pagesCount - 1 else 0,
        'adPlace': themes[random.randint(0, len(themes) - 1)]['id'] if len(themes) > 0 else -1,
        'emptyList': len(themes) == 0
    })
dataset/ETHPy150Open y-a-r-g/idea-color-themes/backend/views/themes.py/index