[DB] Breaking change: User Attribute is now a pickle type
This commit is contained in:
parent
ff6c973eef
commit
9bbcaa5bc9
|
@ -70,8 +70,10 @@ class User(db.Model, ModelSerializeMixin):
|
|||
def has_attribute(self, name):
|
||||
return name in self._attributes
|
||||
|
||||
def get_attribute(self, name):
|
||||
return self._attributes[name].value
|
||||
def get_attribute(self, name, default=None):
|
||||
if name in self._attributes:
|
||||
return self._attributes[name].value
|
||||
return default
|
||||
|
||||
def get_permissions(self):
|
||||
return ["user"] + [permission.name for role in self.roles for permission in role.permissions]
|
||||
|
@ -85,4 +87,4 @@ class _UserAttribute(db.Model, ModelSerializeMixin):
|
|||
id = db.Column("id", db.Integer, primary_key=True)
|
||||
user: User = db.Column("user", db.Integer, db.ForeignKey("user.id"), nullable=False)
|
||||
name: str = db.Column(db.String(30))
|
||||
value: str = db.Column(db.String(192))
|
||||
value: any = db.Column(db.PickleType(protocol=4))
|
||||
|
|
Loading…
Reference in New Issue