def test_respect_navigation_root(self):
        portal = self.layer["portal"]
        login(portal, "admin")

        # Create two subsites i.e create two folders and mark them with
        # INavigationRoot
        for i in xrange(1, 3):
            folder_id = "folder{}".format(i)
            portal.invokeFactory("Folder", folder_id, title="Folder{}".format(i))
            folder = portal[folder_id]
            alsoProvides(folder, INavigationRoot)
        folders = (portal["folder1"], portal["folder2"])

        # Add a content item to each folder
        for f in folders:
            f_id = f.getId()
            f.invokeFactory("Document", "item_in_{}".format(f_id), title="Item In {}".format(f_id))

        # Add a collection to folder1
        folder1 = folders[0]
        folder1.invokeFactory("Collection", "collection1", title="Collection 1")
        collection1 = folder1["collection1"]
        wrapped = ICollection_behavior(collection1)
        wrapped.query = [{"i": "portal_type", "o": "plone.app.querystring.operation.string.is", "v": "Document"}]

        # Check if only the item inside folder1 is returned, since it's a
        # navigation root.
        items = wrapped.results(batch=False)
        ids = [i.getId() for i in items]
        self.assertListEqual(ids, ["item_in_folder1"])
Example #2
0
    def test_collection_templates(self):
        self.portal.acl_users.userFolderAddUser(SITE_OWNER_NAME,
                                                SITE_OWNER_PASSWORD,
                                                ['Manager'], [])
        browser = self.browser
        portal = self.portal
        login(portal, SITE_OWNER_NAME)
        # add an image that will be listed by the collection
        portal.invokeFactory('Image', 'image', title='Image example')

        image = self.portal['image']
        image.image = dummy_image()

        # add a collection, so we can add a query to it
        portal.invokeFactory('Collection',
                             'collection',
                             title='New Collection')
        collection = portal['collection']
        # Search for images
        query = [{
            'i': 'Type',
            'o': 'plone.app.querystring.operation.string.is',
            'v': 'Image',
        }]
        collection.text = RichTextValue(u'Lorem collection ipsum',
                                        'text/plain', 'text/html')

        wrapped = ICollection_behavior(collection)
        # set the query and publish the collection
        wrapped.query = query
        workflow = portal.portal_workflow
        workflow.doActionFor(collection, 'publish')
        commit()
        logout()
        # open a browser to see if our image is in the results
        browser.handleErrors = False
        url = collection.absolute_url()
        browser.open(url)
        self.assertIn('Lorem collection ipsum', browser.contents)
        self.assertIn('Image example', browser.contents)

        # open summary_view template
        browser.open('{0}/@@summary_view'.format(url))
        self.assertIn('Lorem collection ipsum', browser.contents)
        self.assertIn('Image example', browser.contents)

        # open full_view template
        browser.open('{0}/@@full_view'.format(url))
        self.assertIn('Lorem collection ipsum', browser.contents)
        self.assertIn('Image example', browser.contents)

        # open tabular_view template
        browser.open('{0}/@@tabular_view'.format(url))
        self.assertIn('Lorem collection ipsum', browser.contents)
        self.assertIn('Image example', browser.contents)

        # open thumbnail_view template
        browser.open('{0}/@@album_view'.format(url))
        self.assertIn('Lorem collection ipsum', browser.contents)
        self.assertIn('Image example', browser.contents)
    def test_getFoldersAndImages_returning_images(self):
        portal = self.layer['portal']
        login(portal, 'admin')
        # add a collection, so we can add a query to it
        portal.invokeFactory("Collection",
                             "collection",
                             title="New Collection")

        # add example folder
        portal.invokeFactory("Folder",
                             "folder1",
                             title="Folder1")
        folder = portal['folder1']

        # add example image into this folder
        folder.invokeFactory("Image",
                             "image",
                             title="Image example")

        # add another image into the portal root
        portal.invokeFactory("Image",
                             "image",
                             title="Image example")
        query = [{
            'i': 'Type',
            'o': 'plone.app.querystring.operation.string.is',
            'v': 'Image',
        }]
        collection = portal['collection']
        wrapped = ICollection_behavior(collection)
        wrapped.query = query
        imagecount = wrapped.getFoldersAndImages()['total_number_of_images']
        self.assertEqual(imagecount, 2)
Example #4
0
    def test_collection_templates(self):
        browser = self.browser
        portal = self.layer['portal']
        login(portal, 'admin')
        # add an image that will be listed by the collection
        portal.invokeFactory("Image", "image", title="Image example")

        image = self.portal['image']
        image.image = dummy_image()

        # add a collection, so we can add a query to it
        portal.invokeFactory("Collection",
                             "collection",
                             title="New Collection")
        collection = portal['collection']
        # Search for images
        query = [{
            'i': 'Type',
            'o': 'plone.app.querystring.operation.string.is',
            'v': 'Image',
        }]
        collection.text = RichTextValue(u"Lorem collection ipsum",
                                        'text/plain', 'text/html')

        wrapped = ICollection_behavior(collection)
        # set the query and publish the collection
        wrapped.query = query
        workflow = portal.portal_workflow
        workflow.doActionFor(collection, "publish")
        commit()
        logout()
        # open a browser to see if our image is in the results
        browser.handleErrors = False
        url = collection.absolute_url()
        browser.open(url)
        self.assertTrue("Lorem collection ipsum" in browser.contents)
        self.assertTrue("Image example" in browser.contents)

        # open summary_view template
        browser.open('%s/@@summary_view' % url)
        self.assertTrue("Lorem collection ipsum" in browser.contents)
        self.assertTrue("Image example" in browser.contents)

        # open full_view template
        browser.open('%s/@@full_view' % url)
        self.assertTrue("Lorem collection ipsum" in browser.contents)
        self.assertTrue("Image example" in browser.contents)

        # open tabular_view template
        browser.open('%s/@@tabular_view' % url)
        self.assertTrue("Lorem collection ipsum" in browser.contents)
        self.assertTrue("Image example" in browser.contents)

        # open thumbnail_view template
        browser.open('%s/@@album_view' % url)
        self.assertTrue("Lorem collection ipsum" in browser.contents)
        self.assertTrue("Image example" in browser.contents)
Example #5
0
    def migrate_schema_fields(self):
        # migrate the richtext
        super(CollectionMigrator, self).migrate_schema_fields()

        # migrate the rest of the schema into the behavior
        wrapped = ICollection(self.new)
        wrapped.query = self.old.query
        wrapped.sort_on = self.old.sort_on
        wrapped.sort_reversed = self.old.sort_reversed
        wrapped.limit = self.old.limit
        wrapped.customViewFields = self.old.customViewFields
Example #6
0
    def migrate_schema_fields(self):
        # migrate the richtext
        super(CollectionMigrator, self).migrate_schema_fields()

        # migrate the rest of the schema into the behavior
        wrapped = ICollection(self.new)
        wrapped.query = self.old.query
        wrapped.sort_on = self.old.sort_on
        wrapped.sort_reversed = self.old.sort_reversed
        wrapped.limit = self.old.limit
        wrapped.customViewFields = self.old.customViewFields
 def migrate_schema_fields(self):
     migrate_richtextfield(self.old, self.new, 'text', 'text')
     wrapped_new = ICollection(self.new)
     # using migrate_simplefield on 'query' returns the ContentListing obj
     wrapped_new.query = self.old.query
     migrate_simplefield(self.old, wrapped_new, 'sort_on', 'sort_on')
     migrate_simplefield(self.old, wrapped_new, 'sort_reversed',
                         'sort_reversed')
     migrate_simplefield(self.old, wrapped_new, 'limit', 'limit')
     migrate_simplefield(self.old, wrapped_new, 'customViewFields',
                         'customViewFields')
 def migrate_schema_fields(self):
     migrate_richtextfield(self.old, self.new, 'text', 'text')
     wrapped_new = ICollection(self.new)
     # using migrate_simplefield on 'query' returns the ContentListing obj
     wrapped_new.query = self.old.query
     migrate_simplefield(self.old, wrapped_new, 'sort_on', 'sort_on')
     migrate_simplefield(
         self.old, wrapped_new, 'sort_reversed', 'sort_reversed')
     migrate_simplefield(self.old, wrapped_new, 'limit', 'limit')
     migrate_simplefield(
         self.old, wrapped_new, 'customViewFields', 'customViewFields')
Example #9
0
    def test_respect_navigation_root(self):
        self.portal.acl_users.userFolderAddUser(SITE_OWNER_NAME,
                                                SITE_OWNER_PASSWORD,
                                                ['Manager'], [])
        portal = self.portal
        login(portal, SITE_OWNER_NAME)

        # Create two subsites i.e create two folders and mark them with
        # INavigationRoot
        for i in range(1, 3):
            folder_id = 'folder{0}'.format(i)
            portal.invokeFactory('Folder',
                                 folder_id,
                                 title='Folder{0}'.format(i))
            folder = portal[folder_id]
            alsoProvides(folder, INavigationRoot)
        folders = (portal['folder1'], portal['folder2'])

        # Add a content item to each folder
        for f in folders:
            f_id = f.getId()
            f.invokeFactory('Document',
                            'item_in_{0}'.format(f_id),
                            title='Item In {0}'.format(f_id))

        # Add a collection to folder1
        folder1 = folders[0]
        folder1.invokeFactory('Collection',
                              'collection1',
                              title='Collection 1')
        collection1 = folder1['collection1']
        wrapped = ICollection_behavior(collection1)
        wrapped.query = [
            {
                'i': 'portal_type',
                'o': 'plone.app.querystring.operation.string.is',
                'v': 'Document',
            },
            # use a "/" path and navroot works fine!
            {
                'i': 'path',
                'o': 'plone.app.querystring.operation.string.path',
                'v': '/',
            },
        ]

        # Check if only the item inside folder1 is returned, since it's a
        # navigation root.
        items = wrapped.results(batch=False)
        ids = [i.getId() for i in items]
        self.assertListEqual(ids, ['item_in_folder1'])
Example #10
0
    def test_respect_navigation_root(self):
        self.portal.acl_users.userFolderAddUser(
            SITE_OWNER_NAME, SITE_OWNER_PASSWORD, ['Manager'], [])
        portal = self.portal
        login(portal, SITE_OWNER_NAME)

        # Create two subsites i.e create two folders and mark them with
        # INavigationRoot
        for i in range(1, 3):
            folder_id = 'folder{0}'.format(i)
            portal.invokeFactory('Folder',
                                 folder_id,
                                 title='Folder{0}'.format(i))
            folder = portal[folder_id]
            alsoProvides(folder, INavigationRoot)
        folders = (portal['folder1'], portal['folder2'])

        # Add a content item to each folder
        for f in folders:
            f_id = f.getId()
            f.invokeFactory('Document',
                            'item_in_{0}'.format(f_id),
                            title='Item In {0}'.format(f_id))

        # Add a collection to folder1
        folder1 = folders[0]
        folder1.invokeFactory('Collection',
                              'collection1',
                              title='Collection 1')
        collection1 = folder1['collection1']
        wrapped = ICollection_behavior(collection1)
        wrapped.query = [
            {
                'i': 'portal_type',
                'o': 'plone.app.querystring.operation.string.is',
                'v': 'Document',
            },
            # use a "/" path and navroot works fine!
            {
                'i': 'path',
                'o': 'plone.app.querystring.operation.string.path',
                'v': '/',
            },
        ]

        # Check if only the item inside folder1 is returned, since it's a
        # navigation root.
        items = wrapped.results(batch=False)
        ids = [i.getId() for i in items]
        self.assertListEqual(ids, ['item_in_folder1'])
    def test_collection_templates(self):
        browser = self.browser
        portal = self.layer["portal"]
        login(portal, "admin")
        # add an image that will be listed by the collection
        portal.invokeFactory("Image", "image", title="Image example")

        image = self.portal["image"]
        image.image = dummy_image()

        # add a collection, so we can add a query to it
        portal.invokeFactory("Collection", "collection", title="New Collection")
        collection = portal["collection"]
        # Search for images
        query = [{"i": "Type", "o": "plone.app.querystring.operation.string.is", "v": "Image"}]
        collection.text = RichTextValue(u"Lorem collection ipsum", "text/plain", "text/html")

        wrapped = ICollection_behavior(collection)
        # set the query and publish the collection
        wrapped.query = query
        workflow = portal.portal_workflow
        workflow.doActionFor(collection, "publish")
        commit()
        logout()
        # open a browser to see if our image is in the results
        browser.handleErrors = False
        url = collection.absolute_url()
        browser.open(url)
        self.assertTrue("Lorem collection ipsum" in browser.contents)
        self.assertTrue("Image example" in browser.contents)

        # open summary_view template
        browser.open("%s/@@summary_view" % url)
        self.assertTrue("Lorem collection ipsum" in browser.contents)
        self.assertTrue("Image example" in browser.contents)

        # open all_content template
        browser.open("%s/@@all_content" % url)
        self.assertTrue("Lorem collection ipsum" in browser.contents)
        self.assertTrue("Image example" in browser.contents)

        # open tabular_view template
        browser.open("%s/@@tabular_view" % url)
        self.assertTrue("Lorem collection ipsum" in browser.contents)
        self.assertTrue("Image example" in browser.contents)

        # open thumbnail_view template
        browser.open("%s/@@thumbnail_view" % url)
        self.assertTrue("Lorem collection ipsum" in browser.contents)
        self.assertTrue("Image example" in browser.contents)
    def migrate_criteria(self):
        """Migrate old style to new style criteria.

        Plus handling for some special fields.
        """
        # The old Topic has boolean limitNumber and integer itemCount,
        # where the new Collection only has limit.
        adapted = ICollection(self.new)
        if self.old.getLimitNumber():
            adapted.limit = self.old.getItemCount()
        adapted.customViewFields = self.old.getCustomViewFields()

        # Get the old data stored by the beforeChange_criteria method.
        if self._collection_sort_reversed is not None:
            adapted.sort_reversed = self._collection_sort_reversed
        if self._collection_sort_on is not None:
            adapted.sort_on = self._collection_sort_on
        if self._collection_query is not None:
            adapted.query = self._collection_query
Example #13
0
    def migrate_criteria(self):
        """Migrate old style to new style criteria.

        Plus handling for some special fields.
        """
        # The old Topic has boolean limitNumber and integer itemCount,
        # where the new Collection only has limit.
        adapted = ICollection(self.new)
        if self.old.getLimitNumber():
            adapted.limit = self.old.getItemCount()
        adapted.customViewFields = self.old.getCustomViewFields()

        # Get the old data stored by the beforeChange_criteria method.
        if self._collection_sort_reversed is not None:
            adapted.sort_reversed = self._collection_sort_reversed
        if self._collection_sort_on is not None:
            adapted.sort_on = self._collection_sort_on
        if self._collection_query is not None:
            adapted.query = self._collection_query
    def test_getFoldersAndImages_returning_images(self):
        portal = self.layer["portal"]
        login(portal, "admin")
        # add a collection, so we can add a query to it
        portal.invokeFactory("Collection", "collection", title="New Collection")

        # add example folder
        portal.invokeFactory("Folder", "folder1", title="Folder1")
        folder = portal["folder1"]

        # add example image into this folder
        folder.invokeFactory("Image", "image", title="Image example")

        # add another image into the portal root
        portal.invokeFactory("Image", "image", title="Image example")
        query = [{"i": "Type", "o": "plone.app.querystring.operation.string.is", "v": "Image"}]
        collection = portal["collection"]
        wrapped = ICollection_behavior(collection)
        wrapped.query = query
        imagecount = wrapped.getFoldersAndImages()["total_number_of_images"]
        self.assertEqual(imagecount, 2)
    def test_respect_navigation_root(self):
        portal = self.layer['portal']
        login(portal, 'admin')

        # Create two subsites i.e create two folders and mark them with
        # INavigationRoot
        for i in xrange(1, 3):
            folder_id = 'folder{}'.format(i)
            portal.invokeFactory('Folder',
                                 folder_id,
                                 title='Folder{}'.format(i))
            folder = portal[folder_id]
            alsoProvides(folder, INavigationRoot)
        folders = (portal['folder1'], portal['folder2'])

        # Add a content item to each folder
        for f in folders:
            f_id = f.getId()
            f.invokeFactory('Document',
                            'item_in_{}'.format(f_id),
                            title='Item In {}'.format(f_id))

        # Add a collection to folder1
        folder1 = folders[0]
        folder1.invokeFactory('Collection',
                              'collection1',
                              title='Collection 1')
        collection1 = folder1['collection1']
        wrapped = ICollection_behavior(collection1)
        wrapped.query = [{
            'i': 'portal_type',
            'o': 'plone.app.querystring.operation.string.is',
            'v': 'Document',
        }]

        # Check if only the item inside folder1 is returned, since it's a
        # navigation root.
        items = wrapped.results(batch=False)
        ids = [i.getId() for i in items]
        self.assertListEqual(ids, ['item_in_folder1'])
Example #16
0
    def test_respect_navigation_root(self):
        portal = self.layer['portal']
        login(portal, 'admin')

        # Create two subsites i.e create two folders and mark them with
        # INavigationRoot
        for i in xrange(1, 3):
            folder_id = 'folder{}'.format(i)
            portal.invokeFactory('Folder',
                                 folder_id,
                                 title='Folder{}'.format(i))
            folder = portal[folder_id]
            alsoProvides(folder, INavigationRoot)
        folders = (portal['folder1'], portal['folder2'])

        # Add a content item to each folder
        for f in folders:
            f_id = f.getId()
            f.invokeFactory('Document',
                            'item_in_{}'.format(f_id),
                            title='Item In {}'.format(f_id))

        # Add a collection to folder1
        folder1 = folders[0]
        folder1.invokeFactory('Collection',
                              'collection1',
                              title='Collection 1')
        collection1 = folder1['collection1']
        wrapped = ICollection_behavior(collection1)
        wrapped.query = [{
            'i': 'portal_type',
            'o': 'plone.app.querystring.operation.string.is',
            'v': 'Document',
        }]

        # Check if only the item inside folder1 is returned, since it's a
        # navigation root.
        items = wrapped.results(batch=False)
        ids = [i.getId() for i in items]
        self.assertListEqual(ids, ['item_in_folder1'])
    def test_getFoldersAndImages(self):
        portal = self.layer['portal']
        login(portal, 'admin')
        # add a collection, so we can add a query to it
        portal.invokeFactory("Collection",
                             "collection",
                             title="New Collection")

        # add example folder and a subfolder to it, both with same id
        portal.invokeFactory("Folder",
                             "folder1",
                             title="Folder1")
        folder = portal['folder1']

        folder.invokeFactory("Folder",
                             "folder1",
                             title="Folder1")
        subfolder = folder['folder1']
        # add example image into folder and its subfolder
        folder.invokeFactory("Image",
                             "image",
                             title="Image example")

        subfolder.invokeFactory("Image",
                                "another_image",
                                title="Image example")
        query = [{
            'i': 'Type',
            'o': 'plone.app.querystring.operation.string.is',
            'v': 'Folder',
        }]
        collection = portal['collection']
        wrapped = ICollection_behavior(collection)
        wrapped.query = query
        imagecount = wrapped.getFoldersAndImages()['total_number_of_images']
        # The current implementation for getFoldersAndImages will return
        # another_image under subfolder and also under folder
        self.assertEqual(imagecount, 3)
    def test_getFoldersAndImages(self):
        portal = self.layer["portal"]
        login(portal, "admin")
        # add a collection, so we can add a query to it
        portal.invokeFactory("Collection", "collection", title="New Collection")

        # add example folder and a subfolder to it, both with same id
        portal.invokeFactory("Folder", "folder1", title="Folder1")
        folder = portal["folder1"]

        folder.invokeFactory("Folder", "folder1", title="Folder1")
        subfolder = folder["folder1"]
        # add example image into folder and its subfolder
        folder.invokeFactory("Image", "image", title="Image example")

        subfolder.invokeFactory("Image", "another_image", title="Image example")
        query = [{"i": "Type", "o": "plone.app.querystring.operation.string.is", "v": "Folder"}]
        collection = portal["collection"]
        wrapped = ICollection_behavior(collection)
        wrapped.query = query
        imagecount = wrapped.getFoldersAndImages()["total_number_of_images"]
        # The current implementation for getFoldersAndImages will return
        # another_image under subfolder and also under folder
        self.assertEqual(imagecount, 3)
Example #19
0
    def test_collection_templates(self):
        self.portal.acl_users.userFolderAddUser(
            SITE_OWNER_NAME, SITE_OWNER_PASSWORD, ['Manager'], [])
        browser = self.browser
        portal = self.portal
        login(portal, SITE_OWNER_NAME)
        # add an image that will be listed by the collection
        portal.invokeFactory('Image',
                             'image',
                             title='Image example')

        image = self.portal['image']
        image.image = dummy_image()

        # add a collection, so we can add a query to it
        portal.invokeFactory('Collection',
                             'collection',
                             title='New Collection')
        collection = portal['collection']
        # Search for images
        query = [{
            'i': 'Type',
            'o': 'plone.app.querystring.operation.string.is',
            'v': 'Image',
        }]
        collection.text = RichTextValue(
            u'Lorem collection ipsum',
            'text/plain',
            'text/html'
        )

        wrapped = ICollection_behavior(collection)
        # set the query and publish the collection
        wrapped.query = query
        workflow = portal.portal_workflow
        workflow.doActionFor(collection, 'publish')
        commit()
        logout()
        # open a browser to see if our image is in the results
        browser.handleErrors = False
        url = collection.absolute_url()
        browser.open(url)
        self.assertIn('Lorem collection ipsum', browser.contents)
        self.assertIn('Image example', browser.contents)

        # open summary_view template
        browser.open('{0}/@@summary_view'.format(url))
        self.assertIn('Lorem collection ipsum', browser.contents)
        self.assertIn('Image example', browser.contents)

        # open full_view template
        browser.open('{0}/@@full_view'.format(url))
        self.assertIn('Lorem collection ipsum', browser.contents)
        self.assertIn('Image example', browser.contents)

        # open tabular_view template
        browser.open('{0}/@@tabular_view'.format(url))
        self.assertIn('Lorem collection ipsum', browser.contents)
        self.assertIn('Image example', browser.contents)

        # open thumbnail_view template
        browser.open('{0}/@@album_view'.format(url))
        self.assertIn('Lorem collection ipsum', browser.contents)
        self.assertIn('Image example', browser.contents)