diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-11-08 15:16:07 +0100 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-11-08 15:16:07 +0100 |
commit | 015e5ea3004b009bb3b03656d08ef45ee5f793e6 (patch) | |
tree | 81a7de4f98f9299d554ea409a4473c206680a5de /src/web | |
parent | added tag to the API whitelist (diff) | |
download | newspipe-015e5ea3004b009bb3b03656d08ef45ee5f793e6.tar.gz newspipe-015e5ea3004b009bb3b03656d08ef45ee5f793e6.tar.bz2 newspipe-015e5ea3004b009bb3b03656d08ef45ee5f793e6.zip |
bug fix
Diffstat (limited to 'src/web')
-rw-r--r-- | src/web/models/right_mixin.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/web/models/right_mixin.py b/src/web/models/right_mixin.py index 6b2f1b67..1c316f95 100644 --- a/src/web/models/right_mixin.py +++ b/src/web/models/right_mixin.py @@ -1,3 +1,6 @@ +from sqlalchemy.ext.associationproxy import _AssociationList + + class RightMixin: @staticmethod @@ -44,11 +47,17 @@ class RightMixin: def dump(self, role='admin'): if role == 'admin': - dico = {k: getattr(self, k) for k in self.__table__.columns.keys()} + dico = {k: getattr(self, k) + for k in set(self.__table__.columns.keys()) + .union(self.fields_api_read()) + .union(self.fields_base_read())} elif role == 'api': dico = {k: getattr(self, k) for k in self.fields_api_read()} else: dico = {k: getattr(self, k) for k in self.fields_base_read()} if hasattr(self, '__dump__'): dico.update(self.__dump__) + for key, value in dico.items(): # preventing association proxy to die + if isinstance(value, _AssociationList): + dico[key] = list(value) return dico |