def register_time(cls): return db.Column(db.DateTime, default=datetime.now)
def last_login(cls): return db.Column(db.DateTime, default=datetime.now)
def is_superuser(cls): return db.Column(db.Boolean, default=False)
def is_confirmed(cls): return db.Column(db.Boolean, default=False)
def email(cls): return db.Column(db.String(512), nullable=False, unique=True)
def password(cls): return db.Column(db.String(512), nullable=False)
def id(cls): return db.Column(db.Integer, primary_key=True)
def username(cls): return db.Column(db.String(512), nullable=False, unique=True)
# Description: # ************************************************************************** from datetime import datetime from sqlalchemy.ext.declarative import declared_attr from flask_login import UserMixin as _UserMixin from flask_login import login_user, logout_user from werkzeug.security import check_password_hash, generate_password_hash from flask_auth.models import ModelMixin, db from flask_auth.mail import MailMixin from flask_auth.permission.models import UserMixin as PermUserMixin from flask_auth.permission.models import GroupMixin as PermGroupMixin user_group = db.Table( 'user_group', db.Column('user_id', db.Integer, db.ForeignKey('user.id')), db.Column('group_id', db.Integer, db.ForeignKey('group.id'))) class GroupMixin(PermGroupMixin, ModelMixin): @declared_attr def id(cls): return db.Column(db.Integer, primary_key=True) @declared_attr def name(cls): return db.Column(db.String(512), nullable=False, unique=True) @declared_attr def parent_id(cls): return db.Column(db.Integer, db.ForeignKey('group.id'))
def parent_id(cls): return db.Column(db.Integer, db.ForeignKey('group.id'))
def description(cls): return db.Column(db.String(2048))
def resource_type(cls): return db.Column(db.String(81), nullable=False)
def resource(cls): return db.Column(db.String(1024), nullable=False)
def code(cls): return db.Column(db.String(81), default='0000')
# ************************************************************************** # Copyright © 2017 jianglin # File Name: models.py # Author: jianglin # Email: [email protected] # Created: 2017-08-29 16:47:32 (CST) # Last Update:星期一 2018-01-08 11:22:58 (CST) # By: # Description: # ************************************************************************** from sqlalchemy.ext.declarative import declared_attr from flask_auth.models import ModelMixin, db user_permission = db.Table( 'user_permission', db.Column('user_id', db.Integer, db.ForeignKey('user.id')), db.Column('permission_id', db.Integer, db.ForeignKey('permission.id'))) group_permission = db.Table( 'group_permission', db.Column('group_id', db.Integer, db.ForeignKey('group.id')), db.Column('permission_id', db.Integer, db.ForeignKey('permission.id'))) class UserMixin(object): def has_perm_cache(self, *args, **kwargs): return def add_perm(self, action, resource,