<commit_before># -*- coding: utf-8 -*-
# http://google-styleguide.googlecode.com/svn/trunk/pyguide.html

from pytz import timezone, utc

from sqlalchemy.dialects import mysql
from sqlalchemy.orm import relationship
from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound

from smsgw.models import BaseModel, DateMixin
from smsgw.lib.utils import generate_uuid
from smsgw.extensions import bcrypt, db


class User(BaseModel, DateMixin):
    """ User model """

    ROLE_ADMIN = 'admin'
    ROLE_USER = 'user'

    id = db.Column(mysql.INTEGER(10, unsigned=True), primary_key=True)
    uuid = db.Column(mysql.CHAR(36), unique=True, nullable=False,
                     default=generate_uuid)
    email = db.Column(db.String(128), unique=True, nullable=False,
                      server_default="")
    _password = db.Column('password', db.String(60), nullable=False)
    firstName = db.Column(db.String(16))
    lastName = db.Column(db.String(16))
    company = db.Column(db.String(32))
    _timeZoneCode = db.Column("timeZoneCode", db.String(100))
    role = db.Column('role', db.Enum("user", "admin"), default='user',
                     nullable=False)
    isActive = db.Column(db.Boolean, default=True)

    tokens = relationship("UserToken", backref='user')
    templates = relationship("Template", backref='user')
    contacts = relationship("Contact", backref='user', lazy='dynamic')
    tags = relationship("Tag", backref='user', lazy='dynamic')
    applications = relationship("Application", backref='user', lazy='dynamic')
    outbox = relationship("Outbox", backref='user', lazy='dynamic')


    @property
    def password(self):
        """
        Get user password
        :return: {str} hash
        """
        return self._password

    @password.setter
    def password(self, password):
        """
        Set user password as bcrypt hash
        :param password: {str}
        """
        self._password = <PASSWORD>.generate_password_hash(password, 12)
<commit_msg>UserModel: setting up default timezone and prevent password to be null<commit_after># -*- coding: utf-8 -*-
# http://google-styleguide.googlecode.com/svn/trunk/pyguide.html

from pytz import timezone, utc

from sqlalchemy.dialects import mysql
from sqlalchemy.orm import relationship
from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound

from smsgw.models import BaseModel, DateMixin
from smsgw.lib.utils import generate_uuid
from smsgw.extensions import bcrypt, db


class User(BaseModel, DateMixin):
    """ User model """

    ROLE_ADMIN = 'admin'
    ROLE_USER = 'user'

    id = db.Column(mysql.INTEGER(10, unsigned=True), primary_key=True)
    uuid = db.Column(mysql.CHAR(36), unique=True, nullable=False,
                     default=generate_uuid)
    email = db.Column(db.String(128), unique=True, nullable=False,
                      server_default="")
    _password = db.Column('password', db.String(60), nullable=False)
    firstName = db.Column(db.String(16))
    lastName = db.Column(db.String(16))
    company = db.Column(db.String(32))
    _timeZoneCode = db.Column("timeZoneCode", db.String(100),
                              default='Europe/Prague')
    role = db.Column('role', db.Enum("user", "admin"), default='user',
                     nullable=False)
    isActive = db.Column(db.Boolean, default=True)

    tokens = relationship("UserToken", backref='user')
    templates = relationship("Template", backref='user')
    contacts = relationship("Contact", backref='user', lazy='dynamic')
    tags = relationship("Tag", backref='user', lazy='dynamic')
    applications = relationship("Application", backref='user', lazy='dynamic')
    outbox = relationship("Outbox", backref='user', lazy='dynamic')


    @property
    def password(self):
        """
        Get user password
        :return: {str} hash
        """
        return self._password

    @password.setter
    def password(self, password):
        """
        Set user password as bcrypt hash
        :param password: {<PASSWORD>}
        """
        if password is not None:
            self._password = bcrypt.generate_password_hash(password, 12)

{'fraction_non_alphanumeric': 0.13187078109932499, 'fraction_numerical': 0.010125361620057859, 'mean_word_length': 3.312889812889813, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5133134', 'n_tokens_mistral': 1260, 'n_tokens_neox': 1209, 'n_words': 276}