def __call__(self): """ """ try: context_dict = Wrapper(self.context) if self.context.portal_type == 'FormSaveDataAdapter': saveddata = self.context.getSavedFormInputForEdit() context_dict['SavedFormInput'] = saveddata if self.context.portal_type == 'Collage': rowCollages = self.context.objectIds() for rowCollage in rowCollages: context_rowCollage = Wrapper(self.context[rowCollage]) context_dict['_rowCollage_' + rowCollage] = context_rowCollage colCollages = self.context[rowCollage].objectIds() # Row layout manager = IDynamicViewManager(self.context[rowCollage]) rowLayout = manager.getLayout() context_rowCollage['finalObjectLayout'] = rowLayout for colCollage in colCollages: context_colCollage = Wrapper( self.context[rowCollage][colCollage]) context_dict['_colCollage_' + rowCollage + '_' + colCollage] = context_colCollage finalObjects = self.context[rowCollage][ colCollage].objectIds() for finalObject in finalObjects: # finalObject layout manager = IDynamicViewManager( self.context[rowCollage][colCollage] [finalObject]) finalObjectLayout = manager.getLayout() context_finalObject = Wrapper( self.context[rowCollage][colCollage] [finalObject]) context_finalObject[ 'finalObjectLayout'] = finalObjectLayout if finalObject.startswith('alias'): context_dict['_aliasCollage_' + rowCollage + '_' + colCollage + '_' + finalObject] = context_finalObject else: context_dict['_finalObjectCollage_' + rowCollage + '_' + colCollage + '_' + finalObject] = context_finalObject except Exception, e: tb = pprint.pformat(traceback.format_tb(sys.exc_info()[2])) return 'ERROR: exception wrapping object: %s\n%s' % (str(e), tb)
def getLayouts(self): context = self.context # handle aliased objects alias = getattr(self.__parent__, '__alias__', None) if alias: context = alias manager = IDynamicViewManager(context) # lookup active layout active = manager.getLayout() if not active: active, _title = manager.getDefaultLayout() # compile list of registered layouts layouts = manager.getLayouts() # filter out fallback view layouts = filter(lambda name_title: name_title[0] != u'fallback', layouts) # make sure the active layout (which may not be available) is # included if active not in [name for name, title in layouts]: layouts.append( (active, _(u"Missing: $name", mapping={'name': active}))) return [{ 'id': name, 'name': title, 'active': name == active } for (name, title) in layouts]
def __call__(self): context = aq_inner(self.context) manager = IDynamicViewManager(context) layout = manager.getLayout() if not layout: layout, title = manager.getDefaultLayout() if ICollageAlias.providedBy(context): context = context.get_target() # if not set, revert to self.context if not context: context = self.context # transmute request interfaces ifaces = mark_request(self.context, self.request) view = getMultiAdapter((context, self.request), name=layout) # restore interfaces directlyProvides(self.request, ifaces) return view.index
def addToOshmail(path="", layout="", column=None): abspath = urljoin(portal_path(self), path) uid = getUIDForPath(pc, abspath) if uid: alias = insertAlias(column, uid) manager = IDynamicViewManager(alias) manager.setLayout(layout)
def setDynamicSkin(self): skin = self.request['skin'] manager = IDynamicViewManager(self.context) manager.setSkin(skin) self.context.plone_utils.addPortalMessage(_(u'Skin changed.')) self.request.response.redirect(self.context.REQUEST['HTTP_REFERER'])
def setDynamicView(self): layout = self.request['layout'] manager = IDynamicViewManager(self.context) manager.setLayout(layout) self.context.plone_utils.addPortalMessage(_(u'View changed.')) self.request.response.redirect(self.context.REQUEST['HTTP_REFERER'])
def addMultipleToOshmail(items=None, column=None, max=0, layout="", offset=0): for ob in items[:max]: alias = insertAlias(column, ob.UID) manager = IDynamicViewManager(alias) manager.setLayout(layout) for count in range(offset): column.moveObjectsUp(alias.id) cmfutils.getToolByName(self, 'plone_utils').reindexOnReorder(column)
def getSkins(self): context = self.context # handle aliased objects alias = getattr(self.__parent__, '__alias__', None) if alias: context = alias manager = IDynamicViewManager(context) # lookup active skin active = manager.getSkin() if not active: active = 'default' # compile list of registered skins for the layout skins = manager.getSkins(self.request) return [{ 'id': name, 'name': title, 'active': name == active } for (name, title) in skins]
def afterSetUp(self): super(FunctionalTestCase, self).afterSetUp() self.loginAsPortalOwner() wtool = getToolByName(self.portal, 'portal_workflow') # Menu Folder id = self.portal.invokeFactory('Folder', 'menu') ob = getattr(self.portal, id) ob.setTitle('Menu folder') wtool.doActionFor(ob, 'publish') menu = ob self.menu = menu # First item in menu: an internal link to home id = menu.invokeFactory('Link', 'home-link') ob = getattr(menu, id) ob.setTitle('Home') ob.setRemoteUrl('/') wtool.doActionFor(ob, 'publish') elink = ob # Get image file pkg_home = Common.package_home({'__name__': 'collective.collage.megamenu'}) samplesdir = os.path.join(pkg_home, 'tests', 'samples') image_file = file(os.path.join(samplesdir, 'test_image.png')).read() # Image id = self.portal.invokeFactory('Image', 'image') ob = getattr(self.portal, id) ob.setTitle('Test image') ob.setDescription('Dummy description for image') ob.setImage(image_file) # Image is automatically published image = ob # News item with image id = self.portal.invokeFactory('News Item', 'news-item') ob = getattr(self.portal, id) ob.setTitle('Test news item') ob.setDescription('Dummy description for news item') ob.setImage(image_file) wtool.doActionFor(ob, 'publish') ni = ob # Page (Document) id = self.portal.invokeFactory('Document', 'doc') ob = getattr(self.portal, id) ob.setTitle('Test document') ob.setDescription('Dummy description for document') wtool.doActionFor(ob, 'publish') doc = ob # Folder 1 id = self.portal.invokeFactory('Folder', 'folder-1') ob = getattr(self.portal, id) ob.setTitle('Test folder #1') ob.setDescription('Dummy description for folder 1') wtool.doActionFor(ob, 'publish') folder1 = ob # Folder 2 id = self.portal.invokeFactory('Folder', 'folder-2') ob = getattr(self.portal, id) ob.setTitle('Test folder #2') ob.setDescription('Dummy description for folder 2') wtool.doActionFor(ob, 'publish') folder2 = ob # External link id = self.portal.invokeFactory('Link', 'external-link') ob = getattr(self.portal, id) ob.setTitle('External link') ob.setDescription('External link to plone.org') ob.setRemoteUrl('http://plone.org/') wtool.doActionFor(ob, 'publish') elink = ob # Internal link id = self.portal.invokeFactory('Link', 'internal-link') ob = getattr(self.portal, id) ob.setTitle('Internal link') ob.setDescription('Internal link to no-where') ob.setRemoteUrl('/no-where') wtool.doActionFor(ob, 'publish') ilink = ob # Pre-build a Collage with aliases for each of the just created objects # and set the layout id = menu.invokeFactory('Collage', 'collage') collage = getattr(menu, id) collage.setTitle('Collage') wtool.doActionFor(collage, 'publish') self.collage = collage # Row & first column id = collage.invokeFactory('CollageRow', '1') row = getattr(collage, id) manager = IDynamicViewManager(row) manager.setLayout('menu') id = row.invokeFactory('CollageColumn', '1') column = getattr(row, id) manager = IDynamicViewManager(column) manager.setLayout('menu') # Alias for image id = column.invokeFactory('CollageAlias', 'alias-1') alias1 = getattr(column, id) alias1.set_target(image.UID()) manager = IDynamicViewManager(alias1) manager.setLayout('menu') manager.setSkin('collage-megamenu-highlight') # Alias for document id = column.invokeFactory('CollageAlias', 'alias-2') alias2 = getattr(column, id) alias2.set_target(doc.UID()) manager = IDynamicViewManager(alias2) manager.setLayout('menu') manager.setSkin('collage-megamenu-title') # Alias folder 1 id = column.invokeFactory('CollageAlias', 'alias-3') alias3 = getattr(column, id) alias3.set_target(folder1.UID()) manager = IDynamicViewManager(alias3) manager.setLayout('menu') # Alias for folder 2 id = column.invokeFactory('CollageAlias', 'alias-4') alias4 = getattr(column, id) alias4.set_target(folder2.UID()) manager = IDynamicViewManager(alias4) manager.setLayout('menu') # Alias for external link id = column.invokeFactory('CollageAlias', 'alias-5') alias5 = getattr(column, id) alias5.set_target(elink.UID()) manager = IDynamicViewManager(alias5) manager.setLayout('menu') # Alias for internal link id = column.invokeFactory('CollageAlias', 'alias-6') alias6 = getattr(column, id) alias6.set_target(ilink.UID()) manager = IDynamicViewManager(alias6) manager.setLayout('menu') # Second column to add an intro layout id = row.invokeFactory('CollageColumn', '2') column = getattr(row, id) manager = IDynamicViewManager(column) manager.setLayout('menu') # Alias for news item intro id = column.invokeFactory('CollageAlias', 'alias-7') alias7 = getattr(column, id) alias7.set_target(ni.UID()) manager = IDynamicViewManager(alias7) manager.setLayout('intro') # Alternate menu with just one link id = self.portal.invokeFactory('Folder', 'other-menu') ob = getattr(self.portal, id) ob.setTitle('Alternative menu') wtool.doActionFor(ob, 'publish') self.other_menu = ob # Another internal link id = self.other_menu.invokeFactory('Link', 'another-link') ob = getattr(self.other_menu, id) ob.setTitle('Another link') ob.setDescription('Internal link to somewhere') ob.setRemoteUrl('/somewhere') wtool.doActionFor(ob, 'publish')
def getItems(self, contents=None): """Items are a views to render. @param contents: If given fetch the folderListingFolderContents of context. @return: a list of views ready to render. """ # needed to circumvent bug :-( self.request.debug = False # transmute request interfaces ifaces = mark_request(self.context, self.request) views = [] if contents is None: contents = self.getContents() for context in contents: if context is None: continue target = context manager = IDynamicViewManager(context) layout = manager.getLayout() if not layout: layout, title = manager.getDefaultLayout() if ICollageAlias.providedBy(context): target = context.get_target() # if not set, revert to context if target is None: target = context # verify that target is accessible try: getSecurityManager().validate(self, self, target.getId(), target) except Unauthorized: continue # Filter out translation duplicates: # If a non-alias object is translatable, check if its language # is set to the currently selected language or to neutral, # or if it is the canonical version elif isTranslatable(target): language = self.request.get('LANGUAGE', '') if target.Language() not in (language, ''): # Discard the object, if it is not the canonical version # or a translation is available in the requested language. if (not target.isCanonical() or target.getTranslation(language) in contents): continue # If the target is a translation, get the layout defined on # the canonical object, unless a layout has already been # defined on the translation. # Fallback to default layout. if not target.isCanonical(): canmanager = IDynamicViewManager(target.getCanonical()) layout = (manager.getLayout() or canmanager.getLayout() or layout) # don't assume that a layout is always available; note # that we can't use ``queryMultiAdapter`` because even # this lookup might fail hard try: view = getMultiAdapter((target, self.request), name=layout) except ComponentLookupError: view = getMultiAdapter((target, self.request), name='error_collage-view-not-found') view.notfoundlayoutname = layout # store reference to alias if applicable if ICollageAlias.providedBy(context): view.__alias__ = context views.append(view) # restore interfaces directlyProvides(self.request, ifaces) return views
def getItems(self, contents=None): # needed to circumvent bug :-( self.request.debug = False # transmute request interfaces ifaces = directlyProvidedBy(self.request) directlyProvides(self.request, ICollageBrowserLayer) views = [] if not contents: contents = self.context.folderlistingFolderContents() # make sure the languager passed in via set_language is applied correctly plt = getToolByName(self.context, 'portal_languages') binding = self.request.get('LANGUAGE_TOOL', None) language = self.request.get('set_language', plt.getPreferredLanguage()) if binding and binding.LANGUAGE != language: binding.LANGUAGE = language for context in contents: target = context manager = IDynamicViewManager(context) layout = manager.getLayout() if not layout: layout, title = manager.getDefaultLayout() if ICollageAlias.providedBy(context): target = context.get_target() # if not set, revert to context if target is None: target = context # verify that target is accessible try: getSecurityManager().validate(self, self, target.getId(), target) except Unauthorized: continue # Filter out translation duplicates: # If a non-alias object is translatable, check if its language # is set to the currently selected language or to neutral, # or if it is the canonical version elif isTranslatable(target): language = self.request.get('LANGUAGE', '') if target.Language() not in (language, ''): # Discard the object, if it is not the canonical version # or a translation is available in the requested language. if not target.isCanonical() or target.getTranslation( language) in contents: continue # If the target is a translation, get the layout defined on the canonical # object, unless a layout has already been defined on the translation. # Fallback to default layout. if not target.isCanonical(): canmanager = IDynamicViewManager(target.getCanonical()) layout = manager.getLayout() or canmanager.getLayout( ) or layout # assume that a layout is always available view = getMultiAdapter((target, self.request), name=layout) # store reference to alias if applicable if ICollageAlias.providedBy(context): view.__alias__ = context view._collage_context = self.getCollageContext(self.context) views.append(view) # restore interfaces directlyProvides(self.request, ifaces) return views
def setup_content(context): if sht.isNotThisProfile(context, 'plonetheme.zopeorg_setup_content.txt'): return site = context.getSite() sht.delete_items(site, ('front-page', 'news', 'events'), logger) sht.hide_and_retract(site['Members'], logger) content_structure = [ { 'type': 'Image', 'title': 'old.zope.org Screenshot', 'id': u'Screenshotold.zope.org.png', 'opts': { 'setExcludeFromNav': True }, 'data': { 'image': sht.load_file(globals(), 'setupdata/Screenshotold.zope.org.png') } }, { 'type': 'Folder', 'title': u'Teasers', 'opts': { 'workflow': None, # leave private 'setLocallyAllowedTypes': [ 'Teaser', ], 'setImmediatelyAddableTypes': [ 'Teaser', ], 'setLayout': 'folder_summary_view' }, 'childs': [{ 'type': 'Teaser', 'title': 'The World of Zope', 'data': { 'image': sht.load_file(globals(), 'setupdata/teaser_world-of-zope.jpg'), 'importance': u'3' } }] }, { 'type': 'Collage', 'title': u'Start', 'id': 'front-page', 'data': { 'show_title': False, 'show_description': False, }, 'childs': [ { 'type': 'CollageRow', 'title': '', 'id': '1', 'childs': [ # the following column should hold a teaser portlet { 'type': 'CollageColumn', 'title': '', 'id': '1' } ] }, { 'type': 'CollageRow', 'title': '', 'id': '2', 'childs': [ { 'type': 'CollageColumn', 'title': '', 'id': '1', 'childs': [{ 'type': 'Document', 'title': u'Zope Community', 'id': u'front-community', 'opts': { 'setExcludeFromNav': True }, 'data': { 'text': START_ZOPE_COMMUNITY_TEXT } }] }, { 'type': 'CollageColumn', 'title': '', 'id': '2', 'childs': [{ 'type': 'Document', 'title': u'Zope Foundation', 'id': u'front-foundation', 'opts': { 'setExcludeFromNav': True }, 'data': { 'text': START_ZOPE_FOUNDATION_TEXT } }] }, { 'type': 'CollageColumn', 'title': '', 'id': '3', 'childs': [{ 'type': 'Document', 'title': u'Zope.org legacy', 'id': u'front-legacy', 'opts': { 'setExcludeFromNav': True }, 'data': { 'text': START_ZOPEORG_LEGACY_TEXT } }] }, ] }, ] }, { 'type': 'Document', 'title': u'The World of Zope', 'id': 'the-world-of-zope', 'data': { 'text': THE_WORLD_OF_ZOPE_TEXT } }, { 'type': 'Document', 'title': u'News & Events', 'id': u'news-events', 'data': { 'text': NEWS_EVENTS_TEXT } }, { 'type': 'Document', 'title': u'Community', 'id': u'community', 'data': { 'text': COMMUNITY_TEXT } }, { 'type': 'Document', 'title': u'Resources', 'id': u'resources', 'data': { 'text': RESOURCES_TEXT } }, { 'type': 'Document', 'title': u'Zope Foundation', 'id': u'foundation', 'data': { 'text': ZOPE_FOUNDATION_TEXT } }, { 'type': 'Document', 'title': u'Legal', 'id': u'legal', 'opts': { 'setExcludeFromNav': True }, 'data': { 'description': u"""Zope.org Legal Notice.""", 'text': LEGAL_TEXT } }, ] sht.create_item_runner(site, content_structure, logger=logger) #the collage column will hold a portlet, so the view must be portlets-top from Products.Collage.interfaces import IDynamicViewManager manager = IDynamicViewManager(site['front-page']['1']['1']) manager.setLayout('portlets-top') #set the link reference in the teaser site['teasers']['the-world-of-zope'].setLink_internal( site['the-world-of-zope']) site['teasers']['the-world-of-zope'].reindexObject()
def getSkin(self): manager = IDynamicViewManager(self.collage_context) return manager.getSkin()
def createOshMail(self, id="om98", title="Oshmail 98 - 2008", formname=""): pc = self.portal_catalog if not id: msg = "You did not give an ID." self.plone_utils.addPortalMessage(msg) return self.REQUEST.RESPONSE.redirect(formname) if hasattr(aq_base(self), id): msg = "The ID '%s' is already in use!" % id self.plone_utils.addPortalMessage(msg) return self.REQUEST.RESPONSE.redirect(formname) self.invokeFactory(id=id, type_name='Collage') om = getattr(self, id) om.unmarkCreationFlag() om.setTitle(title) # row 1 (teaser // news, events) row1, col1 = insertRow(om) col2 = splitColumn(row1) manager = IDynamicViewManager(row1) manager.setLayout('large-left') path = "en/news/oshmail/latest-news" abspath = urljoin(portal_path(self), path) uid = getUIDForPath(pc, abspath) alias = insertAlias(col1, uid) manager = IDynamicViewManager(alias) manager.setLayout('oshmail') path = "en/news/oshmail/news" abspath = urljoin(portal_path(self), path) uid = getUIDForPath(pc, abspath) alias = insertAlias(col2, uid) manager = IDynamicViewManager(alias) manager.setLayout('right_column') path = "en/news/oshmail/events" abspath = urljoin(portal_path(self), path) uid = getUIDForPath(pc, abspath) alias = insertAlias(col2, uid) manager = IDynamicViewManager(alias) manager.setLayout('right_column') # row 2 (highlights // nothing) row2, col1 = insertRow(om) col2 = splitColumn(row2) manager = IDynamicViewManager(row2) manager.setLayout('large-left') path = "en/news/oshmail/highlights" abspath = urljoin(portal_path(self), path) uid = getUIDForPath(pc, abspath) alias = insertAlias(col1, uid) manager = IDynamicViewManager(alias) manager.setLayout('oshmail') # row 3 (did you know // nothing) row3, col1 = insertRow(om) col2 = splitColumn(row3) manager = IDynamicViewManager(row3) manager.setLayout('large-left') path = "en/news/oshmail/did-you-know" abspath = urljoin(portal_path(self), path) uid = getUIDForPath(pc, abspath) alias = insertAlias(col1, uid) manager = IDynamicViewManager(alias) manager.setLayout('oshmail') # row 4 (site in focus // nothing) row4, col1 = insertRow(om) col2 = splitColumn(row4) manager = IDynamicViewManager(row4) manager.setLayout('large-left') path = "en/news/oshmail/site-in-focus" abspath = urljoin(portal_path(self), path) uid = getUIDForPath(pc, abspath) alias = insertAlias(col1, uid) manager = IDynamicViewManager(alias) manager.setLayout('oshmail') # row 5 (Press releases // nothing) row5, col1 = insertRow(om) col2 = splitColumn(row5) manager = IDynamicViewManager(row5) manager.setLayout('large-left') path = "en/news/oshmail/read-our-latest-press-releases" abspath = urljoin(portal_path(self), path) uid = getUIDForPath(pc, abspath) alias = insertAlias(col1, uid) manager = IDynamicViewManager(alias) manager.setLayout('oshmail') # row 6 (Publications // nothing) row6, col1 = insertRow(om) col2 = splitColumn(row6) manager = IDynamicViewManager(row6) manager.setLayout('large-left') path = "en/news/oshmail/read-our-latest-publications" abspath = urljoin(portal_path(self), path) uid = getUIDForPath(pc, abspath) alias = insertAlias(col1, uid) manager = IDynamicViewManager(alias) manager.setLayout('oshmail') # row 7 (tell a friend) row7, col1 = insertRow(om) path = "en/news/oshmail/tellafriend" abspath = urljoin(portal_path(self), path) uid = getUIDForPath(pc, abspath) alias = insertAlias(col1, uid) om.reindexObject() msg = "Collage template was successfully created" self.plone_utils.addPortalMessage(msg) return self.REQUEST.RESPONSE.redirect(om.absolute_url())
def createOshMail(self, id="", title="", formname="", year='', month='', day='', nocontent=False): if not id: msg = "You did not give an ID." self.plone_utils.addPortalMessage(msg) return self.REQUEST.RESPONSE.redirect(formname) if hasattr(aq_base(self), id): msg = "The ID '%s' is already in use!" % id self.plone_utils.addPortalMessage(msg) return self.REQUEST.RESPONSE.redirect(formname) ### Begin Framework self.invokeFactory(id=id, type_name='Collage') om = getattr(self, id) om.unmarkCreationFlag() om.setTitle(title) row1, col1_1 = insertRow(om) col1_2 = splitColumn(row1) manager = IDynamicViewManager(row1) manager.setLayout('large-left') pc = self.portal_catalog def addToOshmail(path="", layout="", column=None): abspath = urljoin(portal_path(self), path) uid = getUIDForPath(pc, abspath) if uid: alias = insertAlias(column, uid) manager = IDynamicViewManager(alias) manager.setLayout(layout) def addToLeftCol(path=""): addToOshmail(path=path, layout="oshmail", column=col1_1) def addToRightCol(path="", layout=""): addToOshmail(path=path, layout=layout, column=col1_2) def addMultipleToOshmail(items=None, column=None, max=0, layout="", offset=0): for ob in items[:max]: alias = insertAlias(column, ob.UID) manager = IDynamicViewManager(alias) manager.setLayout(layout) for count in range(offset): column.moveObjectsUp(alias.id) cmfutils.getToolByName(self, 'plone_utils').reindexOnReorder(column) def addMultipleToLeftCol(items=None, max=0, layout="oshmail", offset=0): addMultipleToOshmail(items=items, column=col1_1, max=max, layout=layout, offset=offset) def addMultipleToRightCol(items=None, max=0, layout="right_column", offset=0): addMultipleToOshmail(items=items, column=col1_2, max=max, layout=layout, offset=offset) # The 2-column lay-out is now merged into ONE row to have greatest # possible flexibility for the right column. # The lay-out is now: # Highlights || Blog # Did you know || News # Site in focus || Events # Campaign News || # Press releases || # Publications || # Coming soon || # Headings, editable and translated portal content addToRightCol(path="en/news/oshmail/blog") addToRightCol(path="en/news/oshmail/view-the-blog", layout="clickable") addToRightCol(path="en/news/oshmail/news") addToRightCol(path="en/news/oshmail/more-news", layout="clickable") addToRightCol(path="en/news/oshmail/events") addToRightCol(path="en/news/oshmail/more-events", layout="clickable") addToLeftCol(path="en/news/oshmail/highlights") addToLeftCol(path="en/news/oshmail/osh-matters") addToLeftCol(path="en/news/oshmail/read-our-latest-publications") addToLeftCol(path="en/news/oshmail/coming-soon") ## END Framework ## Begin Content if nocontent: msg = "Collage template was successfully created" else: msg = "Collage template including content was successfully created" now = DateTime() try: valid_from = DateTime('%s/%s/%s' % (year, month, day)) except: valid_from = now - 30 query = { 'Language': ['', 'en'], 'review_state': 'published', 'sort_limit': 15, 'sort_on': 'effective', } blog_query = dict( portal_type=['Blog Entry'], sort_order='reverse', ) latest_blog_entry = pc(dict(query.items() + blog_query.items())) addMultipleToRightCol(items=latest_blog_entry, max=1, offset=5) news_query = { 'effective': { 'query': valid_from, 'range': 'min' }, 'expires': { 'query': now, 'range': 'min' }, 'path': { 'query': '/osha/portal/en/news', 'depth': 1 }, 'portal_type': ('News Item', ), 'sort_order': 'reverse', } news = pc(dict(query.items() + news_query.items())) addMultipleToRightCol(items=news, max=15, offset=3) events_query = { 'portal_type': ['Event', 'SPSeminar'], 'path': dict(query=['/osha/portal/en/events', '/osha/portal/en/seminars'], depth=-1), 'end': { 'query': now, 'range': 'min' }, 'sort_on': 'start', } events = pc(dict(query.items() + events_query.items())) addMultipleToRightCol(items=events, max=15, layout="standard", offset=1) highlights_query = { 'path': ['/osha/portal/en/teaser'], 'sort_limit': 2, } highlights = pc( dict(query.items() + news_query.items() + highlights_query.items())) addMultipleToLeftCol(items=highlights, max=2, layout="standard", offset=3) # osh_matters ? publications_query = { 'object_provides': IPublicationEnhanced.__identifier__, 'path': dict(query='/osha/portal/en/publications', depth=-1), 'effective': dict(query=(valid_from, now), range='min:max'), 'sort_limit': 5, } publications = pc(dict(query.items() + publications_query.items())) addMultipleToLeftCol(items=publications, max=5, layout="oshmail_title", offset=1) # coming_soon ? om.reindexObject() self.plone_utils.addPortalMessage(msg) return self.REQUEST.RESPONSE.redirect(om.absolute_url())
def afterSetUp(self): super(FunctionalTestCase, self).afterSetUp() self.loginAsPortalOwner() wtool = getToolByName(self.portal, 'portal_workflow') # News item without image _ = self.portal.invokeFactory('News Item', 'news-item') ob = getattr(self.portal, _) ob.setTitle('Test News item') ob.setExcludeFromNav(True) wtool.doActionFor(ob, 'publish') ni = ob # Page (Document) _ = self.portal.invokeFactory('Document', 'doc') ob = getattr(self.portal, _) ob.setTitle('Test Document') ob.setExcludeFromNav(True) wtool.doActionFor(ob, 'publish') doc = ob # Pre-build an inner (nested) Collage with 2 aliases for # each of the just created objects _ = self.portal.invokeFactory('Collage', 'inner-collage') collage = getattr(self.portal, _) collage.setTitle('Inner Collage') collage.setDescription('This is a nested Collage') collage.setExcludeFromNav(True) wtool.doActionFor(collage, 'publish') self.icollage = collage # Row _ = collage.invokeFactory('CollageRow', '1') row = getattr(collage, _) # Column and Alias for Page _ = row.invokeFactory('CollageColumn', '1') column = getattr(row, _) _ = column.invokeFactory('CollageAlias', 'alias-1') alias1 = getattr(column, _) alias1.set_target(doc.UID()) manager = IDynamicViewManager(alias1) manager.setLayout('standard') # Column and Alias for News Item _ = row.invokeFactory('CollageColumn', '2') column = getattr(row, _) _ = column.invokeFactory('CollageAlias', 'alias-2') alias2 = getattr(column, _) alias2.set_target(ni.UID()) manager = IDynamicViewManager(alias2) manager.setLayout('standard') # Pre-build the outer Collage _ = self.portal.invokeFactory('Collage', 'outer-collage') collage = getattr(self.portal, _) collage.setTitle('Outer Collage') wtool.doActionFor(collage, 'publish') self.ocollage = collage # Row & Column _ = collage.invokeFactory('CollageRow', '1') row = getattr(collage, _) _ = row.invokeFactory('CollageColumn', '1') column = getattr(row, _) # Alias for inner Collage _ = column.invokeFactory('CollageAlias', 'alias') alias = getattr(column, _) alias.set_target(self.icollage.UID())
def delHook(self, tool, sourceObject=None, targetObject=None): """Override standard delHook """ manager = IDynamicViewManager(sourceObject) manager.setLayout(None) return