From 015e5ea3004b009bb3b03656d08ef45ee5f793e6 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Tue, 8 Nov 2016 15:16:07 +0100 Subject: bug fix --- src/web/models/right_mixin.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 -- cgit