コード例 #1
0
 def register_time(cls):
     return db.Column(db.DateTime, default=datetime.now)
コード例 #2
0
 def last_login(cls):
     return db.Column(db.DateTime, default=datetime.now)
コード例 #3
0
 def is_superuser(cls):
     return db.Column(db.Boolean, default=False)
コード例 #4
0
 def is_confirmed(cls):
     return db.Column(db.Boolean, default=False)
コード例 #5
0
 def email(cls):
     return db.Column(db.String(512), nullable=False, unique=True)
コード例 #6
0
 def password(cls):
     return db.Column(db.String(512), nullable=False)
コード例 #7
0
 def id(cls):
     return db.Column(db.Integer, primary_key=True)
コード例 #8
0
 def username(cls):
     return db.Column(db.String(512), nullable=False, unique=True)
コード例 #9
0
# 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'))
コード例 #10
0
 def parent_id(cls):
     return db.Column(db.Integer, db.ForeignKey('group.id'))
コード例 #11
0
 def description(cls):
     return db.Column(db.String(2048))
コード例 #12
0
 def resource_type(cls):
     return db.Column(db.String(81), nullable=False)
コード例 #13
0
 def resource(cls):
     return db.Column(db.String(1024), nullable=False)
コード例 #14
0
 def code(cls):
     return db.Column(db.String(81), default='0000')
コード例 #15
0
# **************************************************************************
# 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,