Esempio n. 1
0
 def getPrettyLink(self, **kwargs):
     """Return the IPrettyLink version of the title."""
     adapted = IPrettyLink(self)
     adapted.showContentIcon = True
     for k, v in kwargs.items():
         setattr(adapted, k, v)
     return adapted.getLink()
Esempio n. 2
0
 def adapted(self,
             showColors=False,
             display_tag_title=False,
             isViewable=True):
     plo = IPrettyLink(self.context)
     plo.showContentIcon = True
     plo.showColors = showColors
     plo.display_tag_title = display_tag_title
     plo.isViewable = isViewable
     plo.notViewableHelpMessage = ''
     return plo
Esempio n. 3
0
    def renderCell(self, item):
        """ """
        obj = self._getObject(item)
        prettyLinker = IPrettyLink(obj)
        prettyLinker.target = '_parent'
        prettyLinker.showContentIcon = True

        annexes = staticInfos = moreInfos = ''

        tool = api.portal.get_tool('portal_plonemeeting')
        cfg = tool.getMeetingConfig(self.context)
        if obj.meta_type == 'MeetingItem':
            isPrivacyViewable = obj.adapted().isPrivacyViewable()
            prettyLinker.isViewable = isPrivacyViewable
            # display annexes and infos if item and item isPrivacyViewable
            if isPrivacyViewable:
                # display moreInfos about item
                # visible columns are one define for items listings or when the meeting is displayed
                # so check where we are
                if IMeeting.providedBy(self.context):
                    # on the meeting
                    if displaying_available_items(self.context):
                        visibleColumns = cfg.getAvailableItemsListVisibleColumns(
                        )
                    else:
                        visibleColumns = cfg.getItemsListVisibleColumns()
                else:
                    visibleColumns = cfg.getItemColumns()
                staticInfos = obj.restrictedTraverse('@@static-infos')(
                    visibleColumns=visibleColumns)
                if self.showMoreInfos:
                    moreInfos = obj.restrictedTraverse('@@item-more-infos')(
                        visibleColumns=visibleColumns)

                # display annexes
                annexes = render_item_annexes(obj, tool)
        elif obj.getTagName() == 'Meeting':
            visibleColumns = cfg.getMeetingColumns()
            staticInfos = obj.restrictedTraverse('@@static-infos')(
                visibleColumns=visibleColumns)
            # check_can_view=True because permission check is not enough
            annexes += obj.restrictedTraverse('@@categorized-childs')(
                portal_type='annex', check_can_view=True)
            # display number of items in meeting title
            contentValue = "{0} [{1}]".format(obj.Title(),
                                              obj.number_of_items())
            prettyLinker.contentValue = contentValue

        if annexes:
            annexes = u"<div class='dashboard_annexes'>{0}</div>".format(
                annexes)

        pretty_link = prettyLinker.getLink()
        return pretty_link + staticInfos + moreInfos + annexes
Esempio n. 4
0
 def test_getLink_caching_showContentIcon(self):
     """Cache takes the 'showContentIcon' parameter into account."""
     adapted = IPrettyLink(self.folder)
     self.assertTrue(adapted.showIcons)
     self.assertFalse(adapted.showContentIcon)
     self.assertFalse(u"contenttype-Folder" in adapted.getLink())
     adapted.showContentIcon = True
     self.assertTrue(u"contenttype-Folder" in adapted.getLink())
     typeInfo = api.portal.get_tool('portal_types')['Folder']
     # setting an icon
     self.invalidate_cache()
     typeInfo.icon_expr = 'string:${portal_url}/myContentIcon.png'
     self.assertFalse(u"contenttype-Folder" in adapted.getLink())
     self.assertTrue(u"plone/myContentIcon.png" in adapted.getLink())
     self.invalidate_cache()
     typeInfo.icon_expr = 'string:${portal_url}/++resource++package/myContentIcon.png'
     self.assertFalse(u"contenttype-Folder" in adapted.getLink())
     self.assertTrue(u"plone/++resource++package/myContentIcon.png" in adapted.getLink())
     self.invalidate_cache()
Esempio n. 5
0
 def test_getLink_caching_showContentIcon(self):
     """Cache takes the 'showContentIcon' parameter into account."""
     adapted = IPrettyLink(self.folder)
     self.assertTrue(adapted.showIcons)
     self.assertFalse(adapted.showContentIcon)
     self.assertFalse(u"contenttype-Folder" in adapted.getLink())
     adapted.showContentIcon = True
     self.assertTrue(u"contenttype-Folder" in adapted.getLink())
     typeInfo = api.portal.get_tool('portal_types')['Folder']
     # setting an icon
     self.invalidate_cache()
     typeInfo.icon_expr = 'string:${portal_url}/myContentIcon.png'
     self.assertFalse(u"contenttype-Folder" in adapted.getLink())
     self.assertTrue(u"plone/myContentIcon.png" in adapted.getLink())
     self.invalidate_cache()
     typeInfo.icon_expr = 'string:${portal_url}/++resource++package/myContentIcon.png'
     self.assertFalse(u"contenttype-Folder" in adapted.getLink())
     self.assertTrue(u"plone/++resource++package/myContentIcon.png" in
                     adapted.getLink())
     self.invalidate_cache()