@permission_required("core.manage_shop")
def images(request, as_string=False, template_name="manage/images/images.html"):
    """
    Display images management.
    """
    req = request.POST if request.method == 'POST' else request.GET
    start = req.get('start')
    # Calculates parameters for display.
    try:
        start = int(start)
    except (__HOLE__, TypeError):
        start = 1

    # filter
    query = req.get('q', '')

    # prepare paginator
    if query:
        images_qs = Image.objects.filter(content_id=None, title__istartswith=query)
    else:
        images_qs = Image.objects.filter(content_id=None)
    paginator = Paginator(images_qs, 50)

    try:
        current_page = paginator.page(start)
    except (EmptyPage, InvalidPage):
        current_page = paginator.page(paginator.num_pages)

    amount_of_images = images_qs.count()

    # Calculate urls
    pagination_data = lfs_pagination(request, current_page, url=request.path)

    pagination_data['total_text'] = ungettext('%(count)d image',
                                              '%(count)d images',
                                              amount_of_images) % {'count': amount_of_images}

    result = render_to_string(template_name, RequestContext(request, {
        "images": current_page.object_list,
        "pagination": pagination_data,
        "query": query
    }))

    if as_string:
        return result
    return HttpResponse(result)
dataset/ETHPy150Open diefenbach/django-lfs/lfs/manage/images/views.py/images