Skip to content

Commit

Permalink
add adapter for rss event item
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-bellenghi committed Mar 7, 2024
1 parent d450d67 commit c91ffdb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/redturtle/volto/adapters/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,11 @@
provides="plone.restapi.interfaces.IBlockFieldLinkIntegrityRetriever"
/>
</configure>

<adapter
factory=".rss.EventItem"
provides="plone.base.interfaces.syndication.IFeedItem"
for="plone.app.contenttypes.interfaces.IEvent
plone.base.interfaces.syndication.IFeed"
/>
</configure>
19 changes: 19 additions & 0 deletions src/redturtle/volto/adapters/rss.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from plone.base.interfaces.syndication import IFeed
from plone.app.contenttypes.interfaces import IEvent
from Products.CMFPlone.browser.syndication.adapters import DexterityItem
from zope.component import adapter
from DateTime import DateTime


@adapter(IEvent, IFeed)
class EventItem(DexterityItem):

@property
def startdate(self):
"""
Same format as other dates in
Products.CMFPlone.browser.syndication.adapters
"""
date = self.context.start.isoformat()
if date:
return DateTime(date)
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<tal:block tal:repeat="item item/categories">
<dc:subject tal:content="item">Item</dc:subject>
</tal:block>
<dc:date tal:content="item/published/HTML4|item/modified/HTML4">Published or last modified date if no published date</dc:date>
<dc:date tal:content="item/startdate/HTML4|item/published/HTML4|item/modified/HTML4">Published or last modified date if no published date</dc:date>
<dc:type tal:content="item/context/portal_type">Type</dc:type>
</item>
</tal:block>
Expand Down

0 comments on commit c91ffdb

Please sign in to comment.