From 9bbcaa5bc91bfaad3d656503ee43444a493bcbef Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 30 Oct 2020 22:18:46 +0100 Subject: [PATCH] [DB] Breaking change: User Attribute is now a pickle type --- flaschengeist/models/user.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/flaschengeist/models/user.py b/flaschengeist/models/user.py index 11df9e5..dc68ddb 100644 --- a/flaschengeist/models/user.py +++ b/flaschengeist/models/user.py @@ -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))