Exemplo n.º 1
0
 def _items(self, **query):
     adapter = IAdapter(self.context)
     sort_limit = adapter.get_feed_number(self.interface)
     if sort_limit:
         query['sort_limit'] = sort_limit
         if isinstance(self, BaseNewsEventFeedViewlet):
             query['sort_limit'] += adapter.get_feed_number(
                 ITopPageMainFeed)
     base = IBaseAdapter(self.context)
     res = []
     for item in base.get_content_listing(**query):
         obj = item.getObject()
         if not isinstance(self, BaseNewsEventFeedViewlet) or (
                 ISiteRoot.providedBy(self.context)
                 and not ITopPageFeed.providedBy(obj)) or (
                     not ISiteRoot.providedBy(self.context)
                     and INavigationRoot.providedBy(self.context)
                     and not IMicroSiteFeed.providedBy(obj)):
             parent = aq_parent(aq_inner(obj))
             res.append({
                 'title': item.Title(),
                 'url': item.getURL(),
                 'parent_title': parent.Title(),
                 'parent_url': parent.absolute_url(),
                 'date': self._date(item),
                 'image': self._image(item),
                 'description': self._description(item),
             })
     if sort_limit:
         return res[:sort_limit]
     return res
Exemplo n.º 2
0
 def test_ITopPageMainFeed(self):
     from sll.templates.interfaces import IAdapter
     from sll.templates.interfaces import ITopPageMainFeed
     root = IAdapter(self.portal)
     self.assertEqual(root.get_feed_number(ITopPageMainFeed), 3)
Exemplo n.º 3
0
 def test_IFolderFeed__hasattr(self):
     from sll.templates.interfaces import IAdapter
     from sll.templates.interfaces import IFolderFeed
     setattr(self.portal, 'folder_feed_number', 10)
     root = IAdapter(self.portal)
     self.assertEqual(root.get_feed_number(IFolderFeed), 10)
Exemplo n.º 4
0
 def test_not_correct_interface(self):
     from sll.templates.interfaces import IAdapter
     from zope.interface import Interface
     root = IAdapter(self.portal)
     with self.assertRaises(ValueError):
         root.get_feed_number(Interface)
Exemplo n.º 5
0
 def test_IFolderFeed(self):
     from sll.templates.interfaces import IAdapter
     from sll.templates.interfaces import IFolderFeed
     root = IAdapter(self.portal)
     self.assertEqual(root.get_feed_number(IFolderFeed), 4)