<commit_before>
from django.contrib.auth.decorators import permission_required
from django.utils.datastructures import SortedDict
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from django.core.paginator import Paginator
from picture.models import Picture
from catalogue.utils import split_tags

# was picture/picture_list.html list (without thumbs)
def picture_list(request, filter=None, get_filter=None, template_name='catalogue/picture_list.html', cache_key=None, context=None):
    """ generates a listing of all books, optionally filtered with a test function """

    if get_filter:
        filt = get_filter()
    pictures_by_author, orphans = Picture.picture_list(filt)
    books_nav = SortedDict()
    for tag in pictures_by_author:
        if pictures_by_author[tag]:
            books_nav.setdefault(tag.sort_key[0], []).append(tag)

    return render_to_response(template_name, locals(),
        context_instance=RequestContext(request))


def picture_list_thumb(request, filter=None, get_filter=None, template_name='picture/picture_list_thumb.html', cache_key=None, context=None):
    book_list = Picture.objects.all()
    if filter:
        book_list = book_list.filter(filter)
    if get_filter:
        book_list = book_list.filter(get_filter())
    book_list = list(book_list)
    book_list.sort(lambda a,b: cmp(a.extra_info['authors'][0], b.extra_info['authors'][0]))
    return render_to_response(template_name, locals(),
                              context_instance=RequestContext(request))

def picture_detail(request, slug):
    picture = get_object_or_404(Picture, slug=slug)

    theme_things = split_tags(picture.related_themes())

    # categories = SortedDict()
    # for tag in picture.tags.iterator():
    #     categories.setdefault(tag.category, []).append(tag)

    themes = theme_things.get('theme', [])
    things = theme_things.get('thing', [])<commit_msg>proper sorting of pictures in gallery view<commit_after>
from django.contrib.auth.decorators import permission_required
from django.utils.datastructures import SortedDict
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from django.core.paginator import Paginator
from picture.models import Picture
from catalogue.utils import split_tags

# was picture/picture_list.html list (without thumbs)
def picture_list(request, filter=None, get_filter=None, template_name='catalogue/picture_list.html', cache_key=None, context=None):
    """ generates a listing of all books, optionally filtered with a test function """

    if get_filter:
        filt = get_filter()
    pictures_by_author, orphans = Picture.picture_list(filt)
    books_nav = SortedDict()
    for tag in pictures_by_author:
        if pictures_by_author[tag]:
            books_nav.setdefault(tag.sort_key[0], []).append(tag)

    return render_to_response(template_name, locals(),
        context_instance=RequestContext(request))


def picture_list_thumb(request, filter=None, get_filter=None, template_name='picture/picture_list_thumb.html', cache_key=None, context=None):
    book_list = Picture.objects.all()
    if filter:
        book_list = book_list.filter(filter)
    if get_filter:
        book_list = book_list.filter(get_filter())
    book_list = book_list.order_by('sort_key_author')
    book_list = list(book_list)
    return render_to_response(template_name, locals(),
                              context_instance=RequestContext(request))

def picture_detail(request, slug):
    picture = get_object_or_404(Picture, slug=slug)

    theme_things = split_tags(picture.related_themes())

    # categories = SortedDict()
    # for tag in picture.tags.iterator():
    #     categories.setdefault(tag.category, []).append(tag)

    themes = theme_things.get('theme', [])
    things = theme_things.get('thing', [])
{'fraction_non_alphanumeric': 0.09992313604919292, 'fraction_numerical': 0.004099410709710479, 'mean_word_length': 4.577142857142857, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7421577', 'n_tokens_mistral': 1179, 'n_tokens_neox': 1134, 'n_words': 248}