def get_block_info(self): """ This method returns a dict containing information to be used in the block's template. """ rss_link_url = "" if self.context.show_rss_link: rss_link_url = "/".join([self.context.absolute_url(), "news_listing_rss"]) more_news_link_url = "" if self.context.show_more_news_link: more_news_link_url = "/".join([self.context.absolute_url(), "news_listing"]) more_news_link_label = self.context.more_news_link_label or translate( _("more_news_link_label", default=u"More News"), context=self.request ) info = { "title": self.context.news_listing_config_title, "show_title": self.context.show_title, "more_news_link_url": more_news_link_url, "more_news_link_label": more_news_link_label, "rss_link_url": rss_link_url or "", "show_lead_image": self.context.show_lead_image, } return info
def is_either_path_or_context(obj): """Checks if not both path and current context are defined. """ if obj.current_context and obj.filter_by_path: raise Invalid(_( u'news_listing_config_current_context_and_path_error', default=u'You can not filter by path and current context ' u'at the same time.') )
def create_news_listing_block(news_folder, event=None): """ This methods creates a news listing block inside the given news folder and is used as a handler for a subscriber listening to the creation of news folders. """ title = translate( _(u'title_default_newslisting_block', u'News'), context=getSite().REQUEST ) api.content.create( news_folder, 'ftw.news.NewsListingBlock', title=title, news_listing_config_title=title, current_context=True, subjects=[], show_title=False, filter_by_path=[], show_more_news_link=True, )
def description(self): return _(u'label_feed_desc', default=u'${title} - News Feed', mapping={'title': self.context.Title().decode('utf-8')})