Beispiel #1
0
 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)
Beispiel #2
0
 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)
Beispiel #3
0
    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'])
Beispiel #4
0
 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)
Beispiel #5
0
 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)
Beispiel #6
0
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())
Beispiel #7
0
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 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()
Beispiel #9
0
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())
Beispiel #10
0
    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())
Beispiel #11
0
 def delHook(self, tool, sourceObject=None, targetObject=None):
     """Override standard delHook
     """
     manager = IDynamicViewManager(sourceObject)
     manager.setLayout(None)
     return
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())
Beispiel #13
0
    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 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())