<commit_before>from mongoengine import *

from blueprints.auth.user_model import User
from datetime import datetime
from flask import url_for


class Forum(Document):
    name = StringField()
    identifier = StringField(unique=True)

    meta = {
        'collection': 'forum_forums',
        'indexes': ['identifier']
    }

    def get_url(self):
        return url_for('forum.view_forum', forum=self.identifier)


class Category(Document):
    name = StringField()
    description = StringField()

    order = IntField()

    forum = ReferenceField(Forum, dbref=False)

    meta = {
        'collection': 'forum_categories',
        'indexes': ['forum']
    }

    def get_boards(self):
        return Board.objects(categories__in=[self])


class Board(Document):
    name = StringField()
    board_id = SequenceField(unique=True)
    description = StringField()

    categories = ListField(ReferenceField(Category, dbref=False))
    forum = ReferenceField(Forum, dbref=False)

    meta = {
        'collection': 'forum_boards',
        'indexes': ['forum', 'categories', 'board_id']
    }

    def get_topic_count(self):
        return Topic.objects(board=self).count()

    def get_url_name(self):
        return self.name.replace(' ', '_')

    def get_url_info(self):
        return {'board_id': self.board_id, 'board_name': self.get_url_name()}

    def get_url(self):
        return url_for('forum.view_board', **self.get_url_info())

    def get_post_url(self):
        return url_for('forum.post_topic', **self.get_url_info())

    def get_last(self):
        return Topic.objects(board=self).order_by('-date').first()



class TopicEdit(EmbeddedDocument):

    author = ReferenceField(User, dbref=False)
    title = StringField()
    date = DateTimeField()
    announcement = BooleanField(default=False)


class Topic(Document):
    title = StringField()

    author = ReferenceField(User, dbref=False)
    date = DateTimeField(default=datetime.utcnow, required=True)
    announcement = BooleanField(default=False)

    topic_url_id = SequenceField(unique=True)

    op = ReferenceField('Post', dbref=False)

    last_editor = ReferenceField(User, dbref=False)
    edits = ListField(EmbeddedDocumentField(TopicEdit))<commit_msg>forum titles can now be up to 80 characters long<commit_after>from mongoengine import *

from blueprints.auth.user_model import User
from datetime import datetime
from flask import url_for


class Forum(Document):
    name = StringField()
    identifier = StringField(unique=True)

    meta = {
        'collection': 'forum_forums',
        'indexes': ['identifier']
    }

    def get_url(self):
        return url_for('forum.view_forum', forum=self.identifier)


class Category(Document):
    name = StringField()
    description = StringField()

    order = IntField()

    forum = ReferenceField(Forum, dbref=False)

    meta = {
        'collection': 'forum_categories',
        'indexes': ['forum']
    }

    def get_boards(self):
        return Board.objects(categories__in=[self])


class Board(Document):
    name = StringField()
    board_id = SequenceField(unique=True)
    description = StringField()

    categories = ListField(ReferenceField(Category, dbref=False))
    forum = ReferenceField(Forum, dbref=False)

    meta = {
        'collection': 'forum_boards',
        'indexes': ['forum', 'categories', 'board_id']
    }

    def get_topic_count(self):
        return Topic.objects(board=self).count()

    def get_url_name(self):
        return self.name.replace(' ', '_')

    def get_url_info(self):
        return {'board_id': self.board_id, 'board_name': self.get_url_name()}

    def get_url(self):
        return url_for('forum.view_board', **self.get_url_info())

    def get_post_url(self):
        return url_for('forum.post_topic', **self.get_url_info())

    def get_last(self):
        return Topic.objects(board=self).order_by('-date').first()


class TopicEdit(EmbeddedDocument):

    author = ReferenceField(User, dbref=False)
    title = StringField()
    date = DateTimeField()
    announcement = BooleanField(default=False)


class Topic(Document):
    title = StringField()

    author = ReferenceField(User, dbref=False)
    date = DateTimeField(default=datetime.utcnow, required=True)
    announcement = BooleanField(default=False)

    topic_url_id = SequenceField(unique=True)

    op = ReferenceField('Post', dbref=False)

    last_editor = ReferenceField(User, dbref=False)
    edits = ListField(EmbeddedDocumentField(TopicEdit))
{'fraction_non_alphanumeric': 0.12178919397697077, 'fraction_numerical': 0.0004428697962798937, 'mean_word_length': 3.671147880041365, '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': '227720', 'n_tokens_mistral': 1416, 'n_tokens_neox': 1345, 'n_words': 276}