def addCollectionAsListingPage(container, title, added_content_types): _createObjectByType('Collection', container, id='aggregator', title=title, #description=description ) aggregator = container['aggregator'] container.setOrdering('unordered') container.setDefaultPage('aggregator') # Set the Collection criteria. #: Sort on the Effective date aggregator.sort_on = u'effective' aggregator.reverse_sort = True #: Query by Type, Review State, Date, etc. query = [ {'i': u'portal_type', 'o': u'plone.app.querystring.operation.selection.is', 'v': added_content_types, }, {'i': u'review_state', 'o': u'plone.app.querystring.operation.selection.is', 'v': [u'published'], }, ] aggregator.query = query aggregator.setLayout('summary_view') _publish(aggregator)
def createSectionWithAggregator(container, added_content_types, id, title, title_msgid, target_language): # Exemple: added_content_types = ['News Item'] createDXSubcontainer(container, 'Folder', id, title, title_msgid, target_language) section = getattr(container, id) if 'aggregator' not in section.keys(): _createObjectByType('Collection', section, id='aggregator', title=title, #description=description ) aggregator = section['aggregator'] section.setOrdering('unordered') section.setDefaultPage('aggregator') _publish(section) # Set the Collection criteria. #: Sort on the Effective date aggregator.sort_on = u'effective' aggregator.reverse_sort = True #: Query by Type, Review State, Date, etc. query = [ {'i': u'portal_type', 'o': u'plone.app.querystring.operation.selection.is', 'v': added_content_types, }, {'i': u'review_state', 'o': u'plone.app.querystring.operation.selection.is', 'v': [u'published'], }, ] if added_content_types == ['Event']: query.insert(1, {'i': 'start', 'o': 'plone.app.querystring.operation.date.afterToday', 'v': '' }, ) aggregator.query = query aggregator.setLayout('summary_view') _publish(aggregator)
def createATSubcontainer(container, type, id, title, title_msgid, target_language): existing_content = container.keys() if id not in existing_content: title = _translate(title_msgid, target_language, title) #description = _translate(u'about-description', target_language, # u"About us.") _createObjectByType(type, container, id=id, title=title, #description=description ) subcontainer = getattr(container, id) subcontainer.setOrdering('unordered') subcontainer.reindexObject() _publish(subcontainer)
def createDXDocument(container, id, title, title_msgid, text, target_language): existing_content = container.keys() if id not in existing_content: title = _translate(title_msgid, target_language, title) #description = _translate(u'about-description', target_language, # u"About us.") item = createContent('Document', id=id, title=title, #description=description, ## text = text ) item = addContentToContainer(container, item) item.text = RichTextValue( text, 'text/html', 'text/x-html-safe' ) #item.setOrdering('unordered') _publish(item) item.reindexObject()
def _createSubObjects(self): """ """ if 'press-releases' not in self.objectIds(): self.invokeFactory("Folder", 'press-releases') obj = self['press-releases'] # FIXME on the way utranslate() is used... obj.setTitle(utranslate('newsroom', 'Press Releases', context=self)) obj.setDescription(utranslate('pressroom', 'Our press releases', context=self)) addCollectionAsListingPage(obj, obj.Title(), ['PressRelease']) _setup_constrains(obj, ['PressRelease']) _publish(obj) obj.reindexObject() if 'press-clips' not in self.objectIds(): self.invokeFactory("Folder", 'press-clips') obj = self['press-clips'] # FIXME on the way utranslate() is used... obj.setTitle(utranslate('newsroom', 'Press Clips', context=self)) obj.setDescription(utranslate('pressroom', 'Our press clips', context=self)) addCollectionAsListingPage(obj, obj.Title(), ['PressClip']) _setup_constrains(obj, ['PressClip']) _publish(obj) obj.reindexObject() if 'press-contacts' not in self.objectIds(): self.invokeFactory("Folder", 'press-contacts') obj = self['press-contacts'] # FIXME on the way utranslate() is used... obj.setTitle(utranslate('newsroom', 'Press Contacts', context=self)) obj.setDescription(utranslate('pressroom', 'Our press contacts', context=self)) addCollectionAsListingPage(obj, obj.Title(), ['PressContact']) _setup_constrains(obj, ['PressContact']) _publish(obj) obj.reindexObject() # if 'press-contacts' not in self.objectIds(): # # # The Press Contacts directory settings... # # FIXME: Look for the conventional position types... # position_types = [{'name': u'Journalist', 'token': u'journalist'}, # {'name': u'Communication Officer', 'token': u'communication_officer'}, # {'name': u'Principal', 'token': u'principal'}, # ] # # # FIXME: Look for the conventional organization types... # organization_types = [{'name': u'Media House', 'token': u'media_house'}, # {'name': u'PR Agency', 'token': u'pr_agency'}, # {'name': u'Internal Marketing Department', 'token': u'internal_marketing_department'}, # ] # # # FIXME: Do we need this ? Make it optional or find a meaningful org level ? # organization_levels = [{'name': u'Any', 'token': u'any'}, # ] # # params = {'title': u"Press Contacts", # 'position_types': position_types, # 'organization_types': organization_types, # 'organization_levels': organization_levels, # } # # self.invokeFactory('directory', 'press-contacts', **params) # directory = self['press-contacts'] # # _publish(directory) transaction.savepoint()