Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typo in Venue serializer #302

Merged
merged 1 commit into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Changelog
[lucabel]
- Add upgrade-step to add missing metadata for image captions.
[cekk]

- Fix typo in Venue serializer that didn't return the right history version.
[cekk]

6.3.4 (2025-03-07)
------------------
Expand Down
2 changes: 1 addition & 1 deletion src/design/plone/contenttypes/restapi/serializers/venue.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def get_venue_offices(self, result):

def __call__(self, version=None, include_items=True):
self.index = "news_venue"
result = super(VenueSerializer, self).__call__(version=None, include_items=True)
result = super().__call__(version=version, include_items=include_items)
result["venue_services"] = self.get_venue_services(result)
result["sede_di"] = self.get_venue_offices(result)
return result
Expand Down
18 changes: 18 additions & 0 deletions src/design/plone/contenttypes/tests/test_ct_luogo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from z3c.relationfield import RelationValue
from zope.component import getUtility
from zope.intid.interfaces import IIntIds
from zope.lifecycleevent import ObjectModifiedEvent
from zope.event import notify

import unittest

Expand Down Expand Up @@ -432,3 +434,19 @@ def test_venue_serializers(self):
if item["id"] in ["venue1", "venue2"]:
self.assertEqual(item["geolocation"]["latitude"], 44.35)
self.assertEqual(item["geolocation"]["longitude"], 11.7)

def test_venue_history_return_right_data(self):
venue = api.content.create(container=self.portal, type="Venue", title="venue1")
venue.description = "aaa"
notify(ObjectModifiedEvent(venue))
venue.description = "aaa bbb"
notify(ObjectModifiedEvent(venue))
commit()

response0 = self.api_session.get(f"{venue.absolute_url()}/@history/0").json()
response1 = self.api_session.get(f"{venue.absolute_url()}/@history/1").json()
response2 = self.api_session.get(f"{venue.absolute_url()}/@history/2").json()

self.assertEqual(response0["description"], "")
self.assertEqual(response1["description"], "aaa")
self.assertEqual(response2["description"], "aaa bbb")