Projet

Général

Profil

0002-user-handle-user.attributes-getter-for-multiple-attr.patch

Paul Marillonnet, 05 avril 2019 17:06

Télécharger (1,32 ko)

Voir les différences:

Subject: [PATCH 2/4] user: handle user.attributes getter for multiple
 attributes (#32025)

 src/authentic2/custom_user/models.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
src/authentic2/custom_user/models.py
66 66
    def __getattr__(self, name):
67 67
        atv = self.values.get(name)
68 68
        if atv:
69
            if not self.verified or atv.verified == self.verified:
70
                return atv.to_python()
69
            if not isinstance(atv, (list, tuple)):
70
                if not self.verified or atv.verified == self.verified:
71
                    return atv.to_python()
72
            else:
73
                # multiple
74
                atvs = atv
75
                atvs_list = []
76
                for atv in atvs:
77
                    if not self.verified or atv.verified == self.verified:
78
                        atvs_list.append(atv)
79
                return list(map(lambda x: x.to_python(), atvs_list))
71 80
        return None
72 81

  
73 82

  
74
-