<commit_before>from sqlalchemy import event

from app import db, get_locale
from app.models.base_model import BaseEntity


class Alv(db.Model, BaseEntity):
    nl_name = db.Column(db.String(128))
    en_name = db.Column(db.String(128))

    date = db.Column(db.Date, nullable=False)

    activity_id = db.Column(db.Integer, db.ForeignKey('activity.id'),
                            nullable=True)
    activity = db.relationship('Activity')

    chairman_user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    chairman = db.relationship('User', foreign_keys=[chairman_user_id])

    secretary_user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    secretary = db.relationship('User', foreign_keys=[secretary_user_id])

    @property
    def presidium(self):
        from app.service import alv_service
        return alv_service.format_presidium(self)

    def get_localized_name(self, locale=None):
        if not locale:
            locale = get_locale()

        if locale == 'nl' and self.nl_name:
            return self.nl_name
        elif locale == 'en' and self.en_name:
            return self.en_name
        elif self.nl_name:
            return self.nl_name + " (Dutch)"
        elif self.en_name:
            return self.en_name + " (Engels)"
        else:
            return 'N/A'


class AlvDocument(db.Model, BaseEntity):
    nl_name = db.Column(db.String(128), nullable=False)
    en_name = db.Column(db.String(128), nullable=False)

    alv_id = db.Column(db.Integer(), db.ForeignKey('alv.id'))
    alv = db.relationship('Alv', backref='documents')

    def get_localized_name(self, locale=None):
        if not locale:
            locale = get_locale()

        if locale == 'nl' and self.nl_name:
            return self.nl_name
        elif locale == 'en' and self.name:
            return self.en_name
        elif self.nl_name:
            return self.nl_name + " (Dutch)"
        elif self.en_name:
            return self.en_name + " (Engels)"
        else:
            return 'N/A'


class AlvDocumentVersion(db.Model, BaseEntity):
    file_id = db.Column(db.Integer(), db.ForeignKey('file.id'))
    file = db.relationship('File')

    alv_document_id = db.Column(db.Integer(), db.ForeignKey('alv_document.id'))
    alv_document = db.relationship('AlvDocument', backref='versions')

<commit_msg>Fixed ALV document naming for english<commit_after>from sqlalchemy import event

from app import db, get_locale
from app.models.base_model import BaseEntity


class Alv(db.Model, BaseEntity):
    nl_name = db.Column(db.String(128))
    en_name = db.Column(db.String(128))

    date = db.Column(db.Date, nullable=False)

    activity_id = db.Column(db.Integer, db.ForeignKey('activity.id'),
                            nullable=True)
    activity = db.relationship('Activity')

    chairman_user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    chairman = db.relationship('User', foreign_keys=[chairman_user_id])

    secretary_user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    secretary = db.relationship('User', foreign_keys=[secretary_user_id])

    @property
    def presidium(self):
        from app.service import alv_service
        return alv_service.format_presidium(self)

    def get_localized_name(self, locale=None):
        if not locale:
            locale = get_locale()

        if locale == 'nl' and self.nl_name:
            return self.nl_name
        elif locale == 'en' and self.en_name:
            return self.en_name
        elif self.nl_name:
            return self.nl_name + " (Dutch)"
        elif self.en_name:
            return self.en_name + " (Engels)"
        else:
            return 'N/A'


class AlvDocument(db.Model, BaseEntity):
    nl_name = db.Column(db.String(128), nullable=False)
    en_name = db.Column(db.String(128), nullable=False)

    alv_id = db.Column(db.Integer(), db.ForeignKey('alv.id'))
    alv = db.relationship('Alv', backref='documents')

    def get_localized_name(self, locale=None):
        if not locale:
            locale = get_locale()

        if locale == 'nl' and self.nl_name:
            return self.nl_name
        elif locale == 'en' and self.en_name:
            return self.en_name
        elif self.nl_name:
            return self.nl_name + " (Dutch)"
        elif self.en_name:
            return self.en_name + " (Engels)"
        else:
            return 'N/A'


class AlvDocumentVersion(db.Model, BaseEntity):
    file_id = db.Column(db.Integer(), db.ForeignKey('file.id'))
    file = db.relationship('File')

    alv_document_id = db.Column(db.Integer(), db.ForeignKey('alv_document.id'))
    alv_document = db.relationship('AlvDocument', backref='versions')


{'fraction_non_alphanumeric': 0.12177985948477751, 'fraction_numerical': 0.005109644453906749, 'mean_word_length': 2.6992125984251967, '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': '3183142', 'n_tokens_mistral': 1537, 'n_tokens_neox': 1475, 'n_words': 303}