def identity(cls): return db.relationship( 'Group', backref=db.backref( 'permissions', cascade='all,delete-orphan', lazy='dynamic'), uselist=False, lazy='joined')
def groups(cls): return db.relationship( 'Group', secondary=group_permission, backref=db.backref( 'permissions', lazy='dynamic'), lazy='dynamic')
class User(db.Model, UserMixin, MailMixin, ModelMixin): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(512), unique=True) email = db.Column(db.String(512), unique=True) password = db.Column(db.String(512), nullable=False) is_superuser = db.Column(db.Boolean, default=False) is_confirmed = db.Column(db.Boolean, default=False) register_time = db.Column(db.DateTime, default=datetime.now()) last_login = db.Column(db.DateTime, default=datetime.now()) groups = db.relationship(Group, secondary=user_group, lazy='dynamic', backref=db.backref('users', lazy='dynamic')) def __str__(self): return self.username def __repr__(self): return '<User %r>' % self.username def set_password(self, raw_password): self.password = generate_password_hash(raw_password) def check_password(self, raw_password): return check_password_hash(self.password, raw_password)
def users(cls): return db.relationship( 'User', secondary=user_permission, backref=db.backref( 'permissions', lazy='dynamic'), lazy='dynamic')
def parent_group(cls): return db.relationship('Group', remote_side=[cls.id], backref=db.backref('child_groups', remote_side=[cls.parent_id], lazy='dynamic'), lazy='joined', uselist=False)
def parent_group(cls): return db.relationship( 'Group', remote_side=[cls.id], backref=db.backref( 'child_groups', remote_side=[cls.parent_id], lazy='dynamic'), lazy='joined', uselist=False)
def groups(cls): return db.relationship('Group', secondary=user_group, backref=db.backref('users', lazy='dynamic'), lazy='dynamic')
def groups(cls): return db.relationship( 'Group', secondary=user_group, backref=db.backref('users', lazy='dynamic'), lazy='dynamic')