<commit_before>#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2014 uralbash <<EMAIL>>
#
# Distributed under terms of the MIT license.

"""
Model of Pages
"""
from sqlalchemy import Boolean, Column, Integer, String, Text
from sqlalchemy.ext.declarative import declarative_base, declared_attr

from sqlalchemy_mptt import BaseNestedSets

Base = declarative_base()


class MPTTPages(Base, BaseNestedSets):
    __tablename__ = "mptt_pages"

    id = Column(Integer, primary_key=True)

    name = Column(String, nullable=False)
    description = Column(Text)

    visible = Column(Boolean)

    # SACRUD
    items_per_page = 20
    verbose_name = u'MPTT pages'
    sacrud_list_template = "/sacrud_pages/base.jinja2"
    sacrud_css_class = {'tinymce': [description],
                        'content': [description],
                        'name': [name], }

    @declared_attr
    def sacrud_list_col(cls):
        return [cls.id, cls.level, cls.tree_id,
                cls.parent_id, cls.left, cls.right]

    def __repr__(self):
        return "MPTTPages(%s, %s, %s, %s) %s" % (self.id, self.left, self.right,
                                                 self.tree_id, self.name)

    @property
    def parents2(self):
        allparents = []
        p = self.parent
        while p:
            allparents.append(p)
            p = p.parent
        return allparents

MPTTPages.register_tree()<commit_msg>clean<commit_after>#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2014 uralbash <<EMAIL>>
#
# Distributed under terms of the MIT license.

"""
Model of Pages
"""
from sqlalchemy import Boolean, Column, Integer, String, Text
from sqlalchemy.ext.declarative import declarative_base, declared_attr

from sqlalchemy_mptt import BaseNestedSets

Base = declarative_base()


class MPTTPages(Base, BaseNestedSets):
    __tablename__ = "mptt_pages"

    id = Column(Integer, primary_key=True)

    name = Column(String, nullable=False)
    description = Column(Text)

    visible = Column(Boolean)

    # SACRUD
    items_per_page = 20
    verbose_name = u'MPTT pages'
    sacrud_list_template = "/sacrud_pages/base.jinja2"
    sacrud_css_class = {'tinymce': [description],
                        'content': [description],
                        'name': [name], }

    @declared_attr
    def sacrud_list_col(cls):
        return [cls.id, cls.level, cls.tree_id,
                cls.parent_id, cls.left, cls.right]

    def __repr__(self):
        return "MPTTPages(%s, %s, %s, %s) %s" % (self.id, self.left, self.right,
                                                 self.tree_id, self.name)

MPTTPages.register_tree()
{'fraction_non_alphanumeric': 0.11644345238095238, 'fraction_numerical': 0.007068452380952381, 'mean_word_length': 2.5474934036939314, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4083383', 'n_tokens_mistral': 921, 'n_tokens_neox': 863, 'n_words': 200}