From fcec10de9919a5810427f3a34581370bf3bc2bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Andrei?= Date: Tue, 23 Jul 2024 12:40:06 -0300 Subject: [PATCH] =?UTF-8?q?Serializar=20data=20de=20anivers=C3=A1rio=20com?= =?UTF-8?q?pleta=20apenas=20para=20quem=20pode=20editar=20o=20conte=C3=BAd?= =?UTF-8?q?o=20(Fix=20#3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/news/3.feature | 1 + .../intranet/serializers/colaborador.py | 11 ++++++++ .../portalbrasil-intranet/news/3.feature | 1 + .../src/components/Views/ColaboradorView.jsx | 25 ++++++++++++++++--- 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 backend/news/3.feature create mode 100644 frontend/packages/portalbrasil-intranet/news/3.feature diff --git a/backend/news/3.feature b/backend/news/3.feature new file mode 100644 index 0000000..34b492f --- /dev/null +++ b/backend/news/3.feature @@ -0,0 +1 @@ +Serializar data de aniversário completa apenas para quem pode editar o conteúdo [@ericof] diff --git a/backend/src/plonegovbr/intranet/serializers/colaborador.py b/backend/src/plonegovbr/intranet/serializers/colaborador.py index f42d381..983c75c 100644 --- a/backend/src/plonegovbr/intranet/serializers/colaborador.py +++ b/backend/src/plonegovbr/intranet/serializers/colaborador.py @@ -1,4 +1,5 @@ from Acquisition import aq_parent +from plone import api from plone.restapi.interfaces import ISerializeToJson from plone.restapi.interfaces import ISerializeToJsonSummary from plone.restapi.serializer.converters import json_compatible @@ -24,6 +25,16 @@ def get_area_info(self): def __call__(self, version=None, include_items=True): result = super().__call__(version, include_items) + birthdate = self.context.birthdate + if self.context.birthdate: + result["aniversario"] = f"{birthdate.day:02d}/{birthdate.month:02d}" + can_edit = api.user.has_permission( + permission="Modify portal content", obj=self.context + ) + if not can_edit: + # Do not show birthdate unless user can edit the content + result.pop("birthdate", None) + result.update( json_compatible({ "area_info": self.get_area_info(), diff --git a/frontend/packages/portalbrasil-intranet/news/3.feature b/frontend/packages/portalbrasil-intranet/news/3.feature new file mode 100644 index 0000000..4eaabf3 --- /dev/null +++ b/frontend/packages/portalbrasil-intranet/news/3.feature @@ -0,0 +1 @@ +Exibe data de aniversário de um colaborador [@ericof] diff --git a/frontend/packages/portalbrasil-intranet/src/components/Views/ColaboradorView.jsx b/frontend/packages/portalbrasil-intranet/src/components/Views/ColaboradorView.jsx index 22b47a1..98f0943 100644 --- a/frontend/packages/portalbrasil-intranet/src/components/Views/ColaboradorView.jsx +++ b/frontend/packages/portalbrasil-intranet/src/components/Views/ColaboradorView.jsx @@ -8,7 +8,7 @@ import { UniversalLink } from '@plone/volto/components'; import { TabPane, Tab } from 'semantic-ui-react'; import { TableRow, TableCell, TableBody, Table } from 'semantic-ui-react'; -const DadosPessoais = ({ area_info, cpf, id }) => { +const DadosPessoais = ({ area_info, aniversario, id }) => { return ( @@ -24,6 +24,12 @@ const DadosPessoais = ({ area_info, cpf, id }) => { )} + {aniversario && ( + + Aniversário + {aniversario} + + )}
); @@ -47,14 +53,27 @@ const DadosContato = ({ email, telefone }) => { const ColaboradorView = (props) => { const { content } = props; - const { title, area_info, id, email, telefone, description, image } = content; + const { + title, + area_info, + id, + email, + aniversario, + telefone, + description, + image, + } = content; const img = image?.scales?.thumb; const panes = [ { menuItem: 'Informações', render: () => ( - + ), },