def test_getLink_caching_contentValue(self): """Cache takes the 'contentValue' parameter into account.""" adapted = IPrettyLink(self.folder) self.assertFalse(adapted.contentValue) self.assertTrue(u"<span class='pretty_link_content'>Folder</span>" in adapted.getLink()) adapted.contentValue = 'Content value' self.assertFalse(u"<span class='pretty_link_content'>Folder</span>" in adapted.getLink()) self.assertTrue(u"<span class='pretty_link_content'>Content value</span>" in adapted.getLink())
def getPrettyLink(self, item): pl = IPrettyLink(item) pl.display_tag_title = False if base_hasattr(pl.context, '_link_portal_type'): pl.additionalCSSClasses = ['contenttype-{}'.format(pl.context._link_portal_type)] else: pl.additionalCSSClasses = ['contenttype-{}'.format(pl.context.portal_type)] pl.contentValue = self.contentValue(item) return pl.getLink()
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
def test_getLink_caching_contentValue(self): """Cache takes the 'contentValue' parameter into account.""" adapted = IPrettyLink(self.folder) self.assertFalse(adapted.contentValue) self.assertTrue( u"<span class='pretty_link_content state-private'>Folder</span>" in adapted.getLink()) adapted.contentValue = 'Content value' self.assertFalse( u"<span class='pretty_link_content state-private'>Folder</span>" in adapted.getLink()) self.assertTrue( u"<span class='pretty_link_content state-private'>Content value</span>" in adapted.getLink())
def getPrettyLink(self, item): pl = IPrettyLink(item) for k, v in self.params.items(): setattr(pl, k, v) pl.contentValue = self.contentValue(item) return pl.getLink()