[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):
|
def has_attribute(self, name):
|
||||||
return name in self._attributes
|
return name in self._attributes
|
||||||
|
|
||||||
def get_attribute(self, name):
|
def get_attribute(self, name, default=None):
|
||||||
return self._attributes[name].value
|
if name in self._attributes:
|
||||||
|
return self._attributes[name].value
|
||||||
|
return default
|
||||||
|
|
||||||
def get_permissions(self):
|
def get_permissions(self):
|
||||||
return ["user"] + [permission.name for role in self.roles for permission in role.permissions]
|
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)
|
id = db.Column("id", db.Integer, primary_key=True)
|
||||||
user: User = db.Column("user", db.Integer, db.ForeignKey("user.id"), nullable=False)
|
user: User = db.Column("user", db.Integer, db.ForeignKey("user.id"), nullable=False)
|
||||||
name: str = db.Column(db.String(30))
|
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