<commit_before># -*- coding: utf-8 -*-
#
# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later.
# Copyright © <NAME>. See NOTICE for more information.
#
from django.contrib.sites.models import Site
from django.db import models
from django.template.loader import render_to_string
from django.utils.translation import ugettext_lazy as _
from slughifi import slughifi
from librarian import NoDublinCore, ParseError, ValidationError
from librarian.dcparser import BookInfo

import apiclient
from catalogue.helpers import cached_in_field
from catalogue.models import BookPublishRecord, ChunkPublishRecord
from catalogue.signals import post_publish
from catalogue.tasks import refresh_instance
from catalogue.xml_tools import compile_text, split_xml


class Book(models.Model):
    """ A document edited on the wiki """

    title = models.CharField(_('title'), max_length=255, db_index=True)
    slug = models.SlugField(_('slug'), max_length=128, unique=True, db_index=True)
    gallery = models.CharField(_('scan gallery name'), max_length=255, blank=True)

    #wl_slug = models.CharField(_('title'), max_length=255, null=True, db_index=True, editable=False)
    parent = models.ForeignKey('self', null=True, blank=True, verbose_name=_('parent'), related_name="children", editable=False)
    parent_number = models.IntegerField(_('parent number'), null=True, blank=True, db_index=True, editable=False)

    # Cache
    _short_html = models.TextField(null=True, blank=True, editable=False)
    _single = models.NullBooleanField(editable=False, db_index=True)
    _new_publishable = models.NullBooleanField(editable=False)
    _published = models.NullBooleanField(editable=False)

    # Managers
    objects = models.Manager()

    class NoTextError(BaseException):
        pass

    class Meta:
        app_label = 'catalogue'
        ordering = ['title']
        verbose_name = _('book')
        verbose_name_plural = _('books')


    # Representing
    # ============

    def __iter__(self):
        return iter(self.chunk_set.all())

    def __getitem__(self, chunk):
        return self.chunk_set.all()[chunk]

    def __len__(self):
        return self.chunk_set.count()
<commit_msg>book sorting fix<commit_after># -*- coding: utf-8 -*-
#
# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later.
# Copyright © <NAME>. See NOTICE for more information.
#
from django.contrib.sites.models import Site
from django.db import models
from django.template.loader import render_to_string
from django.utils.translation import ugettext_lazy as _
from slughifi import slughifi
from librarian import NoDublinCore, ParseError, ValidationError
from librarian.dcparser import BookInfo

import apiclient
from catalogue.helpers import cached_in_field
from catalogue.models import BookPublishRecord, ChunkPublishRecord
from catalogue.signals import post_publish
from catalogue.tasks import refresh_instance
from catalogue.xml_tools import compile_text, split_xml


class Book(models.Model):
    """ A document edited on the wiki """

    title = models.CharField(_('title'), max_length=255, db_index=True)
    slug = models.SlugField(_('slug'), max_length=128, unique=True, db_index=True)
    gallery = models.CharField(_('scan gallery name'), max_length=255, blank=True)

    #wl_slug = models.CharField(_('title'), max_length=255, null=True, db_index=True, editable=False)
    parent = models.ForeignKey('self', null=True, blank=True, verbose_name=_('parent'), related_name="children", editable=False)
    parent_number = models.IntegerField(_('parent number'), null=True, blank=True, db_index=True, editable=False)

    # Cache
    _short_html = models.TextField(null=True, blank=True, editable=False)
    _single = models.NullBooleanField(editable=False, db_index=True)
    _new_publishable = models.NullBooleanField(editable=False)
    _published = models.NullBooleanField(editable=False)

    # Managers
    objects = models.Manager()

    class NoTextError(BaseException):
        pass

    class Meta:
        app_label = 'catalogue'
        ordering = ['title', 'slug']
        verbose_name = _('book')
        verbose_name_plural = _('books')


    # Representing
    # ============

    def __iter__(self):
        return iter(self.chunk_set.all())

    def __getitem__(self, chunk):
        return self.chunk_set.all()[chunk]

    def __len__(self):
        return self.chunk_set.count()

{'fraction_non_alphanumeric': 0.10860239331677579, 'fraction_numerical': 0.006321968841724994, 'mean_word_length': 4.565326633165829, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '1657806', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1302, 'n_words': 331}