Skip to content

Commit

Permalink
Add tipologia_bando to summary serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Nov 7, 2023
1 parent 75630d6 commit 1827b67
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Changelog
- Add @@export-incarichi view that allows to download a csv file with all Persona and their roles.
[cekk]

- Add tipologia_bando to summary serializer.
[cekk]

6.0.21 (2023-10-30)
-------------------

Expand Down
2 changes: 2 additions & 0 deletions src/design/plone/contenttypes/restapi/serializers/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def __call__(self, force_all_metadata=False, force_images=False):
if self.context.portal_type == "Persona":
res["incarichi"] = self.get_incarichi()
if self.context.portal_type == "Bando":
if "tipologia_bando" not in res:
res["tipologia_bando"] = getattr(self.context, "tipologia_bando", "")
if "bando_state" in metadata_fields or self.show_all_metadata_fields:
res["bando_state"] = self.get_bando_state()

Expand Down
17 changes: 17 additions & 0 deletions src/design/plone/contenttypes/tests/test_summary_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,20 @@ def test_summary_do_not_return_tassonomia_argomenti_if_not_in_metadata_fields(se
self.request.form["metadata_fields"] = "_all"
serializer = getMultiAdapter((news, self.request), ISerializeToJsonSummary)()
self.assertIn("tassonomia_argomenti", serializer)

def test_bando_summary_return_tipologia_bando(self):
bando = api.content.create(
container=self.portal,
type="Bando",
title="Bando",
tipologia_bando="foo",
)

commit()

response = self.api_session.get("@search?portal_type=Bando")
result = response.json()
items = result.get("items", [])

self.assertEqual(len(items), 1)
self.assertNotIn("tipologia_bando", bando.tipologia_bando)

0 comments on commit 1827b67

Please sign in to comment.