def createDCPage(self): """ create dc page for non-Datacentre sites """ context = self cat = getToolByName(context, 'portal_catalog') wf = getToolByName(context, 'portal_workflow') pubs = cat.searchResults({ 'object_provides': 'eea.themecentre.interfaces.IThemeCentre', 'path': '/www/SITE/themes/' }) printed = "create dc page for not dc sites" for theme in pubs: themeItem = theme.getObject() themeId = theme.id if not hasattr(themeItem, 'dc'): printed = printed + '\n adding dc page to ' + themeId themeItem.invokeFactory('Document', id='dc') dc = themeItem['dc'] dc.setLayout('dc_view') dc.setTitle('Data services overview') INavigationSectionPosition(dc).section = 'data-center-services' dc.unmarkCreationFlag() # Make sure it's published try: wf.doActionFor( dc, 'publish', comment='published by script for data centres setup.') except Exception, err: logger.info(err) dc.reindexObject() else: printed = printed + '\n dc listing exists for ' + themeId
def interactiveMapsPromotions(self): """find interactive maps via promotions """ context = self cat = getToolByName(context, 'portal_catalog') #wf = getToolByName(context, 'portal_workflow') pubs = cat.searchResults({'portal_type': 'Promotion'}) printed = "Promotions:" for pub in pubs: pubo = pub.getObject() printed = printed + pub.review_state + ' ' + pubo.absolute_url() + '\n' if INavigationSectionPosition(pubo).section: printed = (printed + 'Sections: ' + INavigationSectionPosition(pubo).section + '\n') printed = printed + '************************************************\n' return printed
def setNavContextForLiveMaps(self): """ moving the live maps objects under data centre section. """ context = self cat = getToolByName(context, 'portal_catalog') pubs = cat.searchResults({'navSection': 'quicklinks'}) printed = "STARTED\n" for pub in pubs: pubo = pub.getObject() printed = printed + pub.id + "\n modified \n" printed = printed + '/'.join(pubo.getPhysicalPath()) + "\n" #notify(ObjectModifiedEvent(pubo)) navContext = INavigationSectionPosition(pubo) #navContext.section = 'data-center-services' #notify(ObjectModifiedEvent(pubo)) printed = printed + ' SECTION: ' + navContext.section + "\n" return printed
def setNavContext(self): """ moving the data centric object under data centre section. """ context = self cat = getToolByName(context, 'portal_catalog') pubs = cat.searchResults({'id': 'datasets', 'path': '/www/SITE/themes/'}) printed = "STARTED" for pub in pubs: pubo = pub.getObject() printed = printed + pub.id + "\n modified" printed = printed + '/'.join(pubo.getPhysicalPath()) + "\n" notify(ObjectModifiedEvent(pubo)) navContext = INavigationSectionPosition(pubo) navContext.section = 'data-center-services' notify(ObjectModifiedEvent(pubo)) printed = printed + ' SECTION: ' + navContext.section return printed
def createRODListing(self): """ ROD """ context = self cat = getToolByName(context, 'portal_catalog') wf = getToolByName(context, 'portal_workflow') pubs = cat.searchResults({ 'object_provides': 'eea.themecentre.interfaces.IThemeCentre', 'path': '/www/SITE/themes/' }) printed = "Rod listing" for theme in pubs: themeItem = theme.getObject() themeId = theme.id if not hasattr(themeItem, 'reporting-obligations'): printed = (printed + '\n adding reporting obligations page to ' + themeId) themeItem.invokeFactory('Document', id='reporting-obligations') rod = themeItem['reporting-obligations'] rod.setLayout('rod_listing') rod.setTitle('Countries reporting obligations') INavigationSectionPosition(rod).section = 'data-center-services' rod.unmarkCreationFlag() # Make sure it's published try: wf.doActionFor( rod, 'publish', comment='published by script for data centres setup.') except Exception, err: logger.info(err) rod.reindexObject() else: printed = printed + '\n rod listing exists for ' + themeId
def createIndicatorSections(self): """ Create sections """ context = self cat = getToolByName(context, 'portal_catalog') wf = getToolByName(context, 'portal_workflow') pubs = cat.searchResults({ 'object_provides': 'eea.themecentre.interfaces.IThemeCentre', 'path': '/www/SITE/themes/' }) printed = "Indicators sections for new IMSv3" #image preview for indicators img_preview = context.manage_copyObjects(["img_preview"]) for theme in pubs: themeItem = theme.getObject() printed = printed + themeItem.absolute_url() themeId = theme.id printed = printed + 'fixing a few things in %s' % themeId if hasattr(themeItem, 'indicators'): try: printed = printed + '\nfixing indicators\n' #rename old indicators page themeItem.manage_renameObject('indicators', 'indicators-old') oldindpage = themeItem.manage_cutObjects(["indicators-old"]) oldpage = themeItem['indicators-old'] #create new indicator section #create folder and preview image in it themeItem.invokeFactory('Folder', id='indicators') indf = themeItem['indicators'] #indf.setLayout('dc_view') indf.setTitle('Indicators') # copy old intro text in rich topic area #indf.setRichContent(oldpage.getText()) INavigationSectionPosition( indf).section = 'data-center-services' indf.unmarkCreationFlag() indf.manage_pasteObjects(img_preview) indf.manage_pasteObjects(oldindpage) oldpage = indf['indicators-old'] oldpage.setTitle('Indicators - old') except Exception: printed = printed + "ERROR on theme: " + themeId #publish # Make sure it's published try: wf.doActionFor( indf, 'publish', comment='done by setupmethods for new indicators ims.') except Exception, err: logger.info(err) #reindex indf.reindexObject() #retract old page # Make sure it's published try: wf.doActionFor( oldpage, 'hide', comment='done by setupmethods for new indicators ims.') except Exception, err: logger.info(err) #reindex oldpage.reindexObject()
def themepage_section(self): """ Theme section """ return INavigationSectionPosition(self.context).section