From a2798be7df1b7b163f908dba24dac86cf976f6a4 Mon Sep 17 00:00:00 2001 From: samoel-silva Date: Thu, 19 Sep 2024 15:27:45 -0300 Subject: [PATCH] Exercicio 37: Serializador para pessoa --- .../portal/governo/serializers/configure.zcml | 4 +++ .../src/portal/governo/serializers/pessoa.py | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 backend/src/portal/governo/serializers/pessoa.py diff --git a/backend/src/portal/governo/serializers/configure.zcml b/backend/src/portal/governo/serializers/configure.zcml index 79aacf8..cc60787 100644 --- a/backend/src/portal/governo/serializers/configure.zcml +++ b/backend/src/portal/governo/serializers/configure.zcml @@ -2,6 +2,10 @@ + + + + dict: + result = super().__call__(*args, **kwds) + result["cor"] = "blue" + result["referencias"] = {} + for relation in api.relation.get(target=self.context): + atributo = relation.from_attribute + fonte = relation.from_object + if atributo not in result["referencias"]: + result["referencias"][atributo] = [] + dados = getMultiAdapter((fonte, self.request), ISerializeToJsonSummary)() + result["referencias"][atributo].append(dados) + return result