Esempio n. 1
0
class User(DB.Model, UserMixin):
    id = DB.Column(DB.Integer, primary_key=True)
    email = DB.Column(DB.String(255), unique=True)
    password = DB.Column(DB.String(255))
    active = DB.Column(DB.Boolean())
    confirmed_at = DB.Column(DB.DateTime())
    roles = DB.relationship('Role', secondary=roles_users,
                            backref=DB.backref('users', lazy='dynamic'))
Esempio n. 2
0
class User(DB.Model, UserMixin):
    """Класс для сущности 'Пользователь системы'"""
    __tablename__ = 'user'

    id = DB.Column(DB.Integer, primary_key=True)
    username = DB.Column(DB.String(50), nullable=False, unique=True)
    password = DB.Column(DB.String(255), nullable=False, server_default='')
    active = DB.Column('is_active', DB.Boolean(), nullable=False, server_default='0')

    roles = DB.relationship('Role', secondary='user_roles',
                            backref=DB.backref('users', lazy='dynamic'))

    def __repr__(self):
        return "User(id={id}, username={username}, password={password})". \
            format(id=self.id, username=self.username, password=self.password)