Exemplo n.º 1
0
 def setUp(self):
     self._indexes = [
         FieldIndex('review_state'),
         FieldIndex('portal_type'),
         BooleanIndex('is_default_page'),
         KeywordIndex('subject', extra={'indexed_attrs':
                                        'keyword,subject'}),
         CompositeIndex('comp01',
                        extra=[{
                            'id': 'portal_type',
                            'meta_type': 'FieldIndex',
                            'attributes': ''
                        }, {
                            'id': 'review_state',
                            'meta_type': 'FieldIndex',
                            'attributes': ''
                        }, {
                            'id': 'is_default_page',
                            'meta_type': 'BooleanIndex',
                            'attributes': ''
                        }, {
                            'id': 'subject',
                            'meta_type': 'KeywordIndex',
                            'attributes': 'keyword,subject'
                        }])
     ]
    def setUpPloneSite(self, portal):
        applyProfile(portal, 'plone.app.mosaic:default')
        applyProfile(portal, 'collective.geolocationbehavior:default')
        applyProfile(portal, 'collective.collectionfilter:default')
        applyProfile(portal, 'collective.collectionfilter.tests:testing')

        catalog = api.portal.get_tool(name='portal_catalog')
        if 'exclude_from_nav' not in catalog.indexes():
            catalog.addIndex(
                'exclude_from_nav',
                BooleanIndex('exclude_from_nav'),
            )

        with api.env.adopt_roles(['Manager']):
            portal.invokeFactory(
                'Collection',
                id='testcollection',
                title=u'Test Collection',
                query=[{
                    'i': 'portal_type',
                    'o': 'plone.app.querystring.operation.selection.any',
                    'v': ['Document', 'Event']
                }],
            )
            portal.invokeFactory(
                'Event',
                id='testevent',
                title=u'Test Event',
                start=datetime.now() + timedelta(days=1),
                end=datetime.now() + timedelta(days=2),
                subject=[u'Süper', u'Evänt'],
                exclude_from_nav=False,
            )
            portal.invokeFactory(
                'Document',
                id='testdoc',
                title=u'Test Document 😉',
                text=RichTextValue(u'Ein heißes Test Dokument'),
                subject=[u'Süper', u'Dokumänt'],
                exclude_from_nav=False,
            )
            portal.invokeFactory(
                'Document',
                id='testdoc2',
                title=u'Page 😉',
                text=RichTextValue(u'Ein heißes Test Dokument'),
                subject=[u'Dokumänt'],
                exclude_from_nav=True,
            )
            doc = portal['testdoc']
            # doc.geolocation.latitude = 47.4048832
            # doc.geolocation.longitude = 9.7587760701108
            doc.reindexObject()
Exemplo n.º 3
0
 def _make_catalog(self):
     zcat = ZCatalog('catalog')
     zcat._catalog.addIndex('big', BooleanIndex('big'))
     zcat._catalog.addIndex('date', DateRangeIndex('date', 'start', 'end'))
     zcat._catalog.addIndex('num', FieldIndex('num'))
     zcat._catalog.addIndex('numbers', KeywordIndex('numbers'))
     zcat._catalog.addIndex('path', PathIndex('getPhysicalPath'))
     zcat._catalog.addIndex('uuid', UUIDIndex('num'))
     for i in range(9):
         obj = Dummy(i)
         zcat.catalog_object(obj, str(i))
     return zcat
Exemplo n.º 4
0
 def _make_catalog(self):
     from Products.PluginIndexes.BooleanIndex.BooleanIndex import \
         BooleanIndex
     from Products.PluginIndexes.DateRangeIndex.DateRangeIndex import \
         DateRangeIndex
     from Products.PluginIndexes.FieldIndex.FieldIndex import FieldIndex
     from Products.PluginIndexes.KeywordIndex.KeywordIndex import \
         KeywordIndex
     from Products.PluginIndexes.PathIndex.PathIndex import PathIndex
     from Products.PluginIndexes.UUIDIndex.UUIDIndex import UUIDIndex
     from Products.ZCatalog.ZCatalog import ZCatalog
     zcat = ZCatalog('catalog')
     zcat._catalog.addIndex('big', BooleanIndex('big'))
     zcat._catalog.addIndex('date', DateRangeIndex('date', 'start', 'end'))
     zcat._catalog.addIndex('num', FieldIndex('num'))
     zcat._catalog.addIndex('numbers', KeywordIndex('numbers'))
     zcat._catalog.addIndex('path', PathIndex('getPhysicalPath'))
     zcat._catalog.addIndex('uuid', UUIDIndex('num'))
     for i in range(9):
         obj = dummy(i)
         zcat.catalog_object(obj, str(i))
     return zcat
    def setUpPloneSite(self, portal):
        from plone.formwidget.geolocation.geolocation import Geolocation

        applyProfile(portal, "plone.app.mosaic:default")
        applyProfile(portal, "collective.geolocationbehavior:default")
        applyProfile(portal, "collective.collectionfilter:default")
        applyProfile(portal, "collective.collectionfilter.tests:testing")

        catalog = api.portal.get_tool(name="portal_catalog")
        if "exclude_from_nav" not in catalog.indexes():
            catalog.addIndex(
                "exclude_from_nav",
                BooleanIndex("exclude_from_nav"),
            )

        with api.env.adopt_roles(["Manager"]):
            portal.invokeFactory(
                "Collection",
                id="testcollection",
                title=u"Test Collection",
                query=[{
                    "i": "portal_type",
                    "o": "plone.app.querystring.operation.selection.any",
                    "v": ["Document", "Event"],
                }],
            )
            if six.PY2:
                now = datetime.now()
            else:
                now = datetime.now(pytz.UTC)

            portal.invokeFactory(
                "Event",
                id="testevent",
                title=u"Test Event",
                start=now + timedelta(days=1),
                end=now + timedelta(days=2),
                subject=[u"Süper", u"Evänt"],
                exclude_from_nav=False,
            )
            portal.invokeFactory(
                "Document",
                id="testdoc",
                title=u"Test Document and Document 😉",
                text=RichTextValue(u"Ein heißes Test Dokument", "text/plain",
                                   "text/html"),
                subject=[u"Süper", u"Dokumänt"],
                exclude_from_nav=False,
            )
            portal.invokeFactory(
                "Document",
                id="testdoc2",
                title=u"Page 😉",
                text=RichTextValue(u"Ein heiBes Test Dokument", "text/plain",
                                   "text/html"),
                subject=[u"Dokumänt"],
                exclude_from_nav=True,
            )
            doc = portal["testdoc"]
            doc.geolocation = Geolocation(47.4048832, 9.7587760701108)
            doc.reindexObject()