Skip to content

Commit

Permalink
Fix folder listing template when plone.eventlocation behavior is di…
Browse files Browse the repository at this point in the history
…sabled for Events
  • Loading branch information
petschki committed Nov 15, 2023
1 parent 9131fc7 commit 57d05fe
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions news/679.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix folder listing template when `plone.eventlocation` behavior is disabled for Events.
[petschki]
2 changes: 1 addition & 1 deletion plone/app/contenttypes/browser/templates/listing.pt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

<tal:event condition="python:item_is_event">
<tal:date tal:replace="structure python:view.formatted_date(obj)" />
<span tal:condition="python:obj.location"
<span tal:condition="python:obj.location if hasattr(obj, 'location') else None"
i18n:translate="label_event_byline_location"
>
&mdash;
Expand Down
24 changes: 24 additions & 0 deletions plone/app/contenttypes/tests/test_folder.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import datetime
from datetime import timedelta
from plone.app.contenttypes.browser.folder import FolderView
from plone.app.contenttypes.interfaces import IFolder
from plone.app.contenttypes.testing import ( # noqa
Expand Down Expand Up @@ -232,3 +234,25 @@ def test_list_item_wout_title(self):
# And also in tabular view
self.browser.open(self.folder_url + "/tabular_view")
self.assertIn("doc_wout_title", self.browser.contents)

def test_event_wout_location(self):
# deactivate "plone.eventlocation" from Event behaviors
event_fti = self.portal.portal_types.get("Event")
if not event_fti:
return
event_behaviors = list(event_fti.behaviors)
event_behaviors.remove("plone.eventlocation")
event_fti.behaviors = tuple(event_behaviors)

self.folder.invokeFactory(
"Event",
id="event_wout_location",
title="Event without location",
start=datetime.now() + timedelta(days=1))

import transaction

transaction.commit()

self.browser.open(self.folder_url + "/listing_view")
self.assertIn("Event without location", self.browser.contents)

0 comments on commit 57d05fe

Please sign in to comment.