示例#1
0
 def test_phone_or_cellphone(self):
     add_behavior('Event', IRelatedContacts.__identifier__)
     timezone = 'Europe/Brussels'
     now = datetime.datetime.now()
     self.event = api.content.create(
         container=self.portal,
         type='Event',
         id='event')
     self.event.timezone = timezone
     eventbasic = IEventBasic(self.event)
     eventbasic.start = datetime.datetime(now.year, now.month, now.day, 18)
     eventbasic.end = datetime.datetime(now.year, now.month, now.day, 21)
     self.event.reindexObject()
     view = getMultiAdapter(
         (self.event, self.request), name='event_summary')
     person, organization1, organization2 = add_test_contents(self.portal)
     organization1.phone = ['081/586.100']
     phone_or_cellphone = view.get_phone_or_cellphone(organization1)
     self.assertEqual(phone_or_cellphone[0].get('formated'),
                      '+32 (0) 81 58 61 00')
     organization1.phone = []
     phone_or_cellphone = view.get_phone_or_cellphone(organization1)
     self.assertEqual(len(phone_or_cellphone), 0)
     organization1.cell_phone = ['081/586.101']
     phone_or_cellphone = view.get_phone_or_cellphone(organization1)
     self.assertEqual(phone_or_cellphone[0].get('formated'),
                      '+32 (0) 81 58 61 01')
示例#2
0
    def test_additional_searchable_text(self):
        catalog = api.portal.get_tool("portal_catalog")
        add_behavior("Document", IAdditionalSearchableText.__identifier__)
        add_behavior("Document", IDexterityTextIndexer.__identifier__)
        additional_searchable_text = getattr(self.document,
                                             "additional_searchable_text")
        self.assertEqual(additional_searchable_text, None)
        additional_searchable_text = setattr(self.document,
                                             "additional_searchable_text",
                                             "trash")
        additional_searchable_text = getattr(self.document,
                                             "additional_searchable_text")
        self.assertEqual(additional_searchable_text, "trash")

        # check that additional_searchable_text is correctly indexed
        # and that body text is still indexed
        richtextvalue = RichTextValue(u'richtext_value', 'text/plain',
                                      'text/html')
        self.document.text = richtextvalue
        self.document.reindexObject()

        brain = catalog(UID=self.document.UID())[0]
        indexes = catalog.getIndexDataForRID(brain.getRID())
        searchable_text = indexes['SearchableText']
        self.assertTrue("trash" in searchable_text)
        self.assertTrue("document" in searchable_text)
        self.assertTrue("richtext_value" in searchable_text)
示例#3
0
    def test_folderview_hide_title(self):
        # directlyProvides(self.portal.REQUEST, ICPSkinCoreLayer)  # noqa
        add_behavior('Collection', ICpskinIndexViewSettings.__identifier__)
        configure_folderviews(self.portal)
        collection = self.portal.actualites.actualites
        collection.title = u'My test collection'
        collection.setQuery(
            [{u'i': u'portal_type',
              u'o': u'plone.app.querystring.operation.selection.is',
              u'v': [u'News Item']}, ]
        )
        collection.reindexObject()
        news = api.content.create(
            container=self.folder,
            type='News Item',
            id='testnews')
        news.title = u'My test news'

        api.content.transition(obj=collection, transition='publish')
        api.content.transition(obj=self.portal.actualites,
                               transition='publish')
        view = getMultiAdapter(
            (self.portal, self.portal.REQUEST),
            name='folderview')
        self.assertFalse(view.hide_title(collection))
        self.assertIn('<h2>My test collection</h2>', view())

        collection.hide_title = True
        view = getMultiAdapter(
            (self.portal, self.portal.REQUEST),
            name='folderview')
        self.assertTrue(view.hide_title(collection))
        self.assertNotIn('<h2>My test collection</h2>', view())
示例#4
0
    def test_folderview_event_item_count_homepage(self):
        add_behavior('Collection', ICpskinIndexViewSettings.__identifier__)

        collection = api.content.create(container=self.folder,
                                        type='Collection',
                                        id='collection')

        collection.setQuery(
            [{u'i': u'portal_type',
              u'o': u'plone.app.querystring.operation.selection.is',
              u'v': [u'News Item']}, ]
        )
        collection.item_count_homepage = 1
        api.content.create(
            container=self.folder,
            type='News Item',
            id='testnews')
        api.content.create(
            container=self.folder,
            type='News Item',
            id='testnews2')

        view = getMultiAdapter(
            (self.portal, self.portal.REQUEST), name='folderview')

        result = view.getResults(collection)
        self.assertEqual(len(result['standard-results']), 1)

        collection.item_count_homepage = 2
        result = view.getResults(collection)
        self.assertEqual(len(result['standard-results']), 2)
示例#5
0
    def test_folderview_hide_date(self):
        add_behavior('Collection', ICpskinIndexViewSettings.__identifier__)
        configure_folderviews(self.portal)
        collection = self.portal.actualites.actualites
        collection.setQuery(
            [{u'i': u'portal_type',
              u'o': u'plone.app.querystring.operation.selection.is',
              u'v': [u'News Item']}, ]
        )
        news = api.content.create(
            container=self.folder,
            type='News Item',
            id='testnews')
        api.content.transition(obj=news, transition='publish')
        news.setEffectiveDate(DateTime('2016/07/26'))
        news.reindexObject()
        api.content.transition(obj=collection, transition='publish')
        api.content.transition(obj=self.portal.actualites,
                               transition='publish')
        view = getMultiAdapter(
            (self.portal, self.portal.REQUEST),
            name='folderview')
        news_brain = view.getResults(collection)['standard-results'][0]
        self.assertFalse(view.hide_date(news_brain, collection))
        self.assertIn(u'Jul 26, 2016', view())

        collection.hide_date = True
        view = getMultiAdapter(
            (self.portal, self.portal.REQUEST),
            name='folderview')
        self.assertTrue(view.hide_date(news_brain, collection))
        self.assertNotIn(u'Jul 26, 2016', view())
示例#6
0
    def test_folderview_hide_see_all_link(self):
        add_behavior('Collection', ICpskinIndexViewSettings.__identifier__)
        configure_folderviews(self.portal)
        collection = self.portal.actualites.actualites
        collection.setQuery(
            [{u'i': u'portal_type',
              u'o': u'plone.app.querystring.operation.selection.is',
              u'v': [u'News Item']}, ]
        )
        api.content.create(
            container=self.folder,
            type='News Item',
            id='testnews')
        api.content.transition(obj=collection, transition='publish')
        api.content.transition(obj=self.portal.actualites,
                               transition='publish')
        view = getMultiAdapter(
            (self.portal, self.portal.REQUEST),
            name='folderview')
        self.assertFalse(view.hide_see_all_link(collection))
        self.assertIn(u"Voir l\'ensemble des actualit\xe9s", view())

        collection.hide_see_all_link = True
        view = getMultiAdapter(
            (self.portal, self.portal.REQUEST),
            name='folderview')
        self.assertTrue(view.hide_see_all_link(collection))
        self.assertNotIn(u"Voir l\'ensemble des actualit\xe9s", view())
示例#7
0
    def test_folderview_hide_see_all_link(self):
        add_behavior('Collection', ICpskinIndexViewSettings.__identifier__)
        configure_folderviews(self.portal)
        collection = self.portal.actualites.actualites
        collection.setQuery([
            {
                u'i': u'portal_type',
                u'o': u'plone.app.querystring.operation.selection.is',
                u'v': [u'News Item']
            },
        ])
        api.content.create(container=self.folder,
                           type='News Item',
                           id='testnews')
        api.content.transition(obj=collection, transition='publish')
        api.content.transition(obj=self.portal.actualites,
                               transition='publish')
        view = getMultiAdapter((self.portal, self.portal.REQUEST),
                               name='folderview')
        self.assertFalse(view.hide_see_all_link(collection))
        self.assertIn(u"Voir l\'ensemble des actualit\xe9s", view())

        collection.hide_see_all_link = True
        view = getMultiAdapter((self.portal, self.portal.REQUEST),
                               name='folderview')
        self.assertTrue(view.hide_see_all_link(collection))
        self.assertNotIn(u"Voir l\'ensemble des actualit\xe9s", view())
示例#8
0
    def test_folderview_hide_title(self):
        # directlyProvides(self.portal.REQUEST, ICPSkinCoreLayer)  # noqa
        add_behavior('Collection', ICpskinIndexViewSettings.__identifier__)
        configure_folderviews(self.portal)
        collection = self.portal.actualites.actualites
        collection.title = u'My test collection'
        collection.setQuery([
            {
                u'i': u'portal_type',
                u'o': u'plone.app.querystring.operation.selection.is',
                u'v': [u'News Item']
            },
        ])
        collection.reindexObject()
        news = api.content.create(container=self.folder,
                                  type='News Item',
                                  id='testnews')
        news.title = u'My test news'

        api.content.transition(obj=collection, transition='publish')
        api.content.transition(obj=self.portal.actualites,
                               transition='publish')
        view = getMultiAdapter((self.portal, self.portal.REQUEST),
                               name='folderview')
        self.assertFalse(view.hide_title(collection))
        self.assertIn('<h2>My test collection</h2>', view())

        collection.hide_title = True
        view = getMultiAdapter((self.portal, self.portal.REQUEST),
                               name='folderview')
        self.assertTrue(view.hide_title(collection))
        self.assertNotIn('<h2>My test collection</h2>', view())
示例#9
0
    def test_related_contacts_behavior_view_for_partners(self):
        add_behavior('Event', IRelatedContacts.__identifier__)
        timezone = 'Europe/Brussels'
        now = datetime.datetime.now()
        self.event = api.content.create(
            container=self.portal,
            type='Event',
            id='event')
        self.event.timezone = timezone
        eventbasic = IEventBasic(self.event)
        eventbasic.start = datetime.datetime(now.year, now.month, now.day, 18)
        eventbasic.end = datetime.datetime(now.year, now.month, now.day, 21)
        self.event.reindexObject()
        view = getMultiAdapter(
            (self.event, self.request), name='event_summary')
        self.assertNotIn('partners', view())

        person, organization1, organization2 = add_test_contents(self.portal)

        # set related contact
        intids = getUtility(IIntIds)
        to_id1 = intids.getId(person)
        to_id2 = intids.getId(organization2)
        rv1 = RelationValue(to_id1)
        rv2 = RelationValue(to_id2)
        self.event.partners = [rv1, rv2]
        self.assertIn('partners', view())
示例#10
0
    def test_folderview_hide_date(self):
        add_behavior('Collection', ICpskinIndexViewSettings.__identifier__)
        configure_folderviews(self.portal)
        collection = self.portal.actualites.actualites
        collection.setQuery([
            {
                u'i': u'portal_type',
                u'o': u'plone.app.querystring.operation.selection.is',
                u'v': [u'News Item']
            },
        ])
        news = api.content.create(container=self.folder,
                                  type='News Item',
                                  id='testnews')
        api.content.transition(obj=news, transition='publish')
        news.setEffectiveDate(DateTime('2016/07/26'))
        news.reindexObject()
        api.content.transition(obj=collection, transition='publish')
        api.content.transition(obj=self.portal.actualites,
                               transition='publish')
        view = getMultiAdapter((self.portal, self.portal.REQUEST),
                               name='folderview')
        news_brain = view.getResults(collection)['standard-results'][0]
        self.assertFalse(view.hide_date(news_brain, collection))
        self.assertIn(u'Jul 26, 2016', view())

        collection.hide_date = True
        view = getMultiAdapter((self.portal, self.portal.REQUEST),
                               name='folderview')
        self.assertTrue(view.hide_date(news_brain, collection))
        self.assertNotIn(u'Jul 26, 2016', view())
示例#11
0
    def test_related_contacts_behavior_view_for_contact(self):
        add_behavior('Event', IRelatedContacts.__identifier__)
        timezone = 'Europe/Brussels'
        now = datetime.datetime.now()
        self.event = api.content.create(container=self.portal,
                                        type='Event',
                                        id='event')
        self.event.timezone = timezone
        eventbasic = IEventBasic(self.event)
        eventbasic.start = datetime.datetime(now.year, now.month, now.day, 18)
        eventbasic.end = datetime.datetime(now.year, now.month, now.day, 21)
        self.event.reindexObject()
        view = getMultiAdapter((self.event, self.request),
                               name='event_summary')
        person, organization1, organization2 = add_test_contents(self.portal)

        # set related contact
        intids = getUtility(IIntIds)
        to_id = intids.getId(organization1)
        rv = RelationValue(to_id)
        self.event.contact = rv
        self.assertEqual(view.get_website(organization1), None)
        organization1.website = 'www.foo.bar'
        self.assertEqual(
            view.get_website(organization1),
            '<a class="event_website" href="http://www.foo.bar" target="_blank">www.foo.bar</a>'  # noqa
        )
示例#12
0
 def test_phone_or_cellphone(self):
     add_behavior('Event', IRelatedContacts.__identifier__)
     timezone = 'Europe/Brussels'
     now = datetime.datetime.now()
     self.event = api.content.create(container=self.portal,
                                     type='Event',
                                     id='event')
     self.event.timezone = timezone
     eventbasic = IEventBasic(self.event)
     eventbasic.start = datetime.datetime(now.year, now.month, now.day, 18)
     eventbasic.end = datetime.datetime(now.year, now.month, now.day, 21)
     self.event.reindexObject()
     view = getMultiAdapter((self.event, self.request),
                            name='event_summary')
     person, organization1, organization2 = add_test_contents(self.portal)
     organization1.phone = ['081/586.100']
     phone_or_cellphone = view.get_phone_or_cellphone(organization1)
     self.assertEqual(phone_or_cellphone[0].get('formated'),
                      '+32 (0) 81 58 61 00')
     organization1.phone = []
     phone_or_cellphone = view.get_phone_or_cellphone(organization1)
     self.assertEqual(len(phone_or_cellphone), 0)
     organization1.cell_phone = ['081/586.101']
     phone_or_cellphone = view.get_phone_or_cellphone(organization1)
     self.assertEqual(phone_or_cellphone[0].get('formated'),
                      '+32 (0) 81 58 61 01')
示例#13
0
    def test_related_contacts_behavior_view_for_partners(self):
        add_behavior('Event', IRelatedContacts.__identifier__)
        timezone = 'Europe/Brussels'
        now = datetime.datetime.now()
        self.event = api.content.create(container=self.portal,
                                        type='Event',
                                        id='event')
        self.event.timezone = timezone
        eventbasic = IEventBasic(self.event)
        eventbasic.start = datetime.datetime(now.year, now.month, now.day, 18)
        eventbasic.end = datetime.datetime(now.year, now.month, now.day, 21)
        self.event.reindexObject()
        view = getMultiAdapter((self.event, self.request),
                               name='event_summary')
        self.assertNotIn('partners', view())

        person, organization1, organization2 = add_test_contents(self.portal)

        # set related contact
        intids = getUtility(IIntIds)
        to_id1 = intids.getId(person)
        to_id2 = intids.getId(organization2)
        rv1 = RelationValue(to_id1)
        rv2 = RelationValue(to_id2)
        self.event.partners = [rv1, rv2]
        self.assertIn('partners', view())
示例#14
0
    def test_related_contacts_behavior_view_for_contact(self):
        add_behavior('Event', IRelatedContacts.__identifier__)
        timezone = 'Europe/Brussels'
        now = datetime.datetime.now()
        self.event = api.content.create(
            container=self.portal,
            type='Event',
            id='event')
        self.event.timezone = timezone
        eventbasic = IEventBasic(self.event)
        eventbasic.start = datetime.datetime(now.year, now.month, now.day, 18)
        eventbasic.end = datetime.datetime(now.year, now.month, now.day, 21)
        self.event.reindexObject()
        view = getMultiAdapter(
            (self.event, self.request), name='event_summary')
        person, organization1, organization2 = add_test_contents(self.portal)

        # set related contact
        intids = getUtility(IIntIds)
        to_id = intids.getId(organization1)
        rv = RelationValue(to_id)
        self.event.contact = rv
        self.assertEqual(
            view.get_website(organization1),
            None
        )
        organization1.website = 'www.foo.bar'
        self.assertEqual(
            view.get_website(organization1),
            '<a class="event_website" href="http://www.foo.bar" target="_blank">www.foo.bar</a>'  # noqa
        )
示例#15
0
    def test_use_parent_address(self):
        add_behavior(
            'Event', 'cpskin.core.behaviors.metadata.IRelatedContacts')
        event = api.content.create(
            container=self.folder,
            type='Event',
            id='myevent'
        )

        # getting viewlet
        view = BrowserView(event, self.request)
        manager_name = 'plone.belowcontentbody'
        manager = queryMultiAdapter(
            (event, self.request, view),
            IViewletManager,
            manager_name,
            default=None)
        self.assertIsNotNone(manager)
        manager.update()

        my_viewlet = [
            v for v in manager.viewlets if v.__name__ == 'cpskin.below_related_contacts']  # noqa
        self.assertEqual(len(my_viewlet), 1)
        below_viewlet = my_viewlet[0]

        contacts = below_viewlet.get_contacts()
        self.assertEqual(contacts, [])
        self.assertFalse(below_viewlet.available())

        # add some contacts
        applyProfile(self.portal, 'collective.contact.core:default')
        directory = api.content.create(
            container=self.portal, type='directory', id='directory')
        person = api.content.create(
            container=directory, type='person', id='person')
        person.firstname = u'Foo'
        person.lastname = u'Bar'
        person.gender = u'F'
        person.street = u'Zoning Industriel'
        person.number = u'34'
        person.zip_code = u'5190'
        person.city = u'Mornimont'
        person.use_parent_address = True

        # set related contact
        intids = getUtility(IIntIds)
        to_id = intids.getId(person)
        rv = RelationValue(to_id)
        event.belowContentContact = event.belowContentContact + [rv]
        self.assertTrue(below_viewlet.available())
        contacts = below_viewlet.get_contacts()
        self.assertEqual(len(contacts), 1)
        self.assertEqual(contacts[0], person)

        self.assertNotIn('Mornimont', below_viewlet.render())
        self.assertIn('Foo Bar', below_viewlet.render())

        event.belowVisbileFields = ('zip_code',)
        self.assertNotIn('5190', below_viewlet.render())
        self.assertNotIn('Foo', below_viewlet.render())
示例#16
0
 def test_related_contacts(self):
     add_behavior("Document", IRelatedContacts.__identifier__)
     aboveContentContact = getattr(self.document, "aboveContentContact")
     self.assertEqual(aboveContentContact, [])
     belowContentContact = getattr(self.document, "belowContentContact")
     self.assertFalse(belowContentContact)
     remove_behavior("Document", IRelatedContacts.__identifier__)
示例#17
0
 def test_related_contacts(self):
     add_behavior("Document", IRelatedContacts.__identifier__)
     aboveContentContact = getattr(self.document, "aboveContentContact")
     self.assertEqual(aboveContentContact, [])
     belowContentContact = getattr(self.document, "belowContentContact")
     self.assertFalse(belowContentContact)
     remove_behavior("Document", IRelatedContacts.__identifier__)
示例#18
0
 def setUpPloneSite(self, portal):
     # super(CPSkinMinisiteLayer).setUpPloneSite(portal)
     portal.portal_workflow.setDefaultChain('simple_publication_workflow')
     # applyProfile(portal, 'plone.app.contenttypes:plone-content')
     applyProfile(portal, 'cpskin.minisite:testing')
     add_behavior('Document', IHiddenTags.__identifier__)
     ISecuritySchema(portal).set_enable_self_reg(True)
示例#19
0
    def test_folderview_setting_image_scale(self):
        add_behavior(
            'Collection',
            'cpskin.core.behaviors.indexview.ICpskinIndexViewSettings')
        configure_folderviews(self.portal)
        news = api.content.create(
            container=self.folder,
            type='News Item',
            id='testnewsitem')
        api.content.transition(obj=news, transition='publish')
        collection = self.portal.actualites.actualites
        view = getMultiAdapter(
            (self.portal, self.request), name='folderview')
        self.assertEqual(collection.collection_image_scale, 'collection')
        self.assertEqual(collection.slider_image_scale, 'slider')
        self.assertEqual(collection.carousel_image_scale, 'carousel')
        scale = view.collection_image_scale(collection, news)
        self.assertFalse(scale)
        add_leadimage_from_file(news, 'visuel.png')
        scale = view.collection_image_scale(collection, news)
        self.assertTrue('height="116"' in scale)

        collection.collection_image_scale = 'thumb'
        scale = view.collection_image_scale(collection, news)
        self.assertTrue('height="250"' in scale)
示例#20
0
    def test_folderview_event_item_count_homepage(self):
        add_behavior('Collection', ICpskinIndexViewSettings.__identifier__)

        collection = api.content.create(container=self.folder,
                                        type='Collection',
                                        id='collection')

        collection.setQuery([
            {
                u'i': u'portal_type',
                u'o': u'plone.app.querystring.operation.selection.is',
                u'v': [u'News Item']
            },
        ])
        collection.item_count_homepage = 1
        api.content.create(container=self.folder,
                           type='News Item',
                           id='testnews')
        api.content.create(container=self.folder,
                           type='News Item',
                           id='testnews2')

        view = getMultiAdapter((self.portal, self.portal.REQUEST),
                               name='folderview')

        result = view.getResults(collection)
        self.assertEqual(len(result['standard-results']), 1)

        collection.item_count_homepage = 2
        result = view.getResults(collection)
        self.assertEqual(len(result['standard-results']), 2)
示例#21
0
    def test_folderview_setting_named_link(self):
        add_behavior(
            'Collection',
            'cpskin.core.behaviors.indexview.ICpskinIndexViewSettings')
        configure_folderviews(self.portal)
        news = api.content.create(
            container=self.folder,
            type='News Item',
            id='testnewsitem')
        api.content.transition(obj=news, transition='publish')
        api.content.transition(obj=self.portal.actualites.actualites,
                               transition='publish')
        api.content.transition(obj=self.portal.actualites,
                               transition='publish')
        collection = self.portal.actualites.actualites
        link_text = getattr(collection, 'link_text')
        self.assertEqual(link_text, '')
        view = getMultiAdapter((self.portal, self.request), name='folderview')
        voir_lensemble_des = view.see_all(collection)
        self.assertEqual(voir_lensemble_des,
                         "Voir l'ensemble des actualit\xc3\xa9s")

        collection.link_text = u'Voir toutes les actualit\xc3\xa9s'
        voir_lensemble_des = view.see_all(collection)
        self.assertEqual(voir_lensemble_des,
                         'Voir toutes les actualit\xc3\x83\xc2\xa9s')
        self.assertTrue('Voir toutes les actualit' in view.index())
示例#22
0
    def test_orga_geo_contents_view(self):
        # add some contacts
        applyProfile(self.portal, 'collective.contact.core:default')
        directory = api.content.create(container=self.portal,
                                       type='directory',
                                       id='directory')
        person = api.content.create(container=directory,
                                    type='person',
                                    id='person')
        person.street = u'Rue de la Vieille Sambre'
        person.number = u'34'
        person.zip_code = u'5190'
        person.city = u'Mornimont'

        add_behavior('person', ICoordinates.__identifier__)

        form = getMultiAdapter((self.portal, self.portal.REQUEST),
                               name='set-geo-contents-form')
        form.request.form = {'form.widgets.content_types': [u'person']}
        form.update()

        coord = ICoordinates(person).coordinates
        self.assertFalse(coord.startswith('POINT '))
        form.handleApply(form, 'Ok')
        coord = ICoordinates(person).coordinates
        self.assertTrue(coord.startswith('POINT '))
示例#23
0
    def test_folderview_setting_named_link(self):
        add_behavior(
            'Collection',
            'cpskin.core.behaviors.indexview.ICpskinIndexViewSettings')
        configure_folderviews(self.portal)
        news = api.content.create(container=self.folder,
                                  type='News Item',
                                  id='testnewsitem')
        api.content.transition(obj=news, transition='publish')
        api.content.transition(obj=self.portal.actualites.actualites,
                               transition='publish')
        api.content.transition(obj=self.portal.actualites,
                               transition='publish')
        collection = self.portal.actualites.actualites
        link_text = getattr(collection, 'link_text')
        self.assertEqual(link_text, '')
        view = getMultiAdapter((self.portal, self.request), name='folderview')
        voir_lensemble_des = view.see_all(collection)
        self.assertEqual(voir_lensemble_des,
                         "Voir l'ensemble des actualit\xc3\xa9s")

        collection.link_text = u'Voir toutes les actualit\xc3\xa9s'
        voir_lensemble_des = view.see_all(collection)
        self.assertEqual(voir_lensemble_des,
                         'Voir toutes les actualit\xc3\x83\xc2\xa9s')
        self.assertTrue('Voir toutes les actualit' in view.index())
示例#24
0
 def test_related_contacts_see_logo_in_popup(self):
     add_behavior("Document", IRelatedContacts.__identifier__)
     see_logo_in_popup = getattr(self.document, "see_logo_in_popup")
     self.assertTrue(see_logo_in_popup)
     setattr(self.document, "see_logo_in_popup", False)
     see_logo_in_popup = getattr(self.document, "see_logo_in_popup")
     self.assertFalse(see_logo_in_popup)
     remove_behavior("Document", IRelatedContacts.__identifier__)
示例#25
0
 def test_related_contacts_see_logo_in_popup(self):
     add_behavior("Document", IRelatedContacts.__identifier__)
     see_logo_in_popup = getattr(self.document, "see_logo_in_popup")
     self.assertTrue(see_logo_in_popup)
     setattr(self.document, "see_logo_in_popup", False)
     see_logo_in_popup = getattr(self.document, "see_logo_in_popup")
     self.assertFalse(see_logo_in_popup)
     remove_behavior("Document", IRelatedContacts.__identifier__)
示例#26
0
 def test_keyword_indexview_behavior(self):
     add_behavior(
         'Collection',
         'cpskin.core.behaviors.indexview.ICpskinIndexViewSettings')
     collection = api.content.create(container=self.folder,
                                     type='Collection',
                                     id='testcollection')
     self.assertEqual(getattr(collection, 'index_view_keywords'), None)
     collection.index_view_keywords = (u'homepage', )
     self.assertEqual(getattr(collection, 'index_view_keywords'),
                      (u'homepage', ))
示例#27
0
 def test_keyword_indexview_behavior(self):
     add_behavior(
         'Collection',
         'cpskin.core.behaviors.indexview.ICpskinIndexViewSettings')
     collection = api.content.create(
         container=self.folder,
         type='Collection',
         id='testcollection')
     self.assertEqual(getattr(collection, 'index_view_keywords'), None)
     collection.index_view_keywords = (u'homepage',)
     self.assertEqual(
         getattr(collection, 'index_view_keywords'), (u'homepage',))
示例#28
0
    def test_folderview_event_category(self):
        applyProfile(self.portal, 'collective.taxonomy:default')
        add_behavior('Collection', ICpskinIndexViewSettings.__identifier__)

        utility = queryUtility(ITaxonomy, name='collective.taxonomy.test')
        collection = api.content.create(container=self.folder,
                                        type='Collection',
                                        id='collection')
        collection.taxonomy_category = 'taxonomy_test'
        collection.reindexObject()

        taxonomy_test = schema.Set(
            title=u'taxonomy_test',
            description=u'taxonomy description schema',
            required=False,
            value_type=schema.Choice(
                vocabulary=u'collective.taxonomy.test'),
        )
        portal_types = api.portal.get_tool('portal_types')
        fti = portal_types.get('Event')
        event_schema = fti.lookupSchema()
        schemaeditor = IEditableSchema(event_schema)
        schemaeditor.addField(taxonomy_test, name='taxonomy_test')
        notify(ObjectAddedEvent(taxonomy_test, event_schema))
        notify(FieldAddedEvent(fti, taxonomy_test))
        event = api.content.create(
            container=self.folder,
            type='Event',
            id='testevent')
        simple_tax = [val for val in utility.data['en'].values()]
        event.taxonomy_test = set(simple_tax[0])

        view = getMultiAdapter(
            (self.portal, self.portal.REQUEST), name='folderview')

        see_categories = view.see_categories(collection)
        self.assertTrue(see_categories)
        collection.taxonomy_category = ''
        see_categories = view.see_categories(collection)
        self.assertFalse(see_categories)
        collection.taxonomy_category = 'taxonomy_test'
        categories = view.get_categories(collection, event)
        self.assertEqual(categories, 'Information Science')

        event.taxonomy_test = set(simple_tax[0:2])
        categories = view.get_categories(collection, event)
        self.assertEqual(
            categories,
            'Book Collecting, Information Science')

        event.taxonomy_test = set()
        categories = view.get_categories(collection, event)
        self.assertEqual(categories, '')
示例#29
0
 def test_hidden_tags(self):
     add_behavior("Document", IHiddenTags.__identifier__)
     hiddenTags = getattr(self.document, "hiddenTags")
     self.assertEqual(hiddenTags, None)
     self.document.hiddenTags = ("mon-test",)
     self.document.reindexObject()
     hiddenTags = getattr(self.document, "hiddenTags")
     self.assertEqual(hiddenTags, ("mon-test",))
     catalog = api.portal.get_tool("portal_catalog")
     query = {"hiddenTags": "mon-test"}
     brains = catalog(query)
     self.assertEqual(len(brains), 1)
     self.assertEqual(brains[0].getObject(), self.document)
示例#30
0
 def test_hidden_tags(self):
     add_behavior("Document", IHiddenTags.__identifier__)
     hiddenTags = getattr(self.document, "hiddenTags")
     self.assertEqual(hiddenTags, None)
     self.document.hiddenTags = ("mon-test", )
     self.document.reindexObject()
     hiddenTags = getattr(self.document, "hiddenTags")
     self.assertEqual(hiddenTags, ("mon-test", ))
     catalog = api.portal.get_tool("portal_catalog")
     query = {"hiddenTags": "mon-test"}
     brains = catalog(query)
     self.assertEqual(len(brains), 1)
     self.assertEqual(brains[0].getObject(), self.document)
示例#31
0
 def test_additional_searchable_text(self):
     add_behavior("Document", IAdditionalSearchableText.__identifier__)
     additional_searchable_text = getattr(
         self.document, "additional_searchable_text"
     )
     self.assertEqual(additional_searchable_text, None)
     additional_searchable_text = setattr(
         self.document, "additional_searchable_text", "trash"
     )
     additional_searchable_text = getattr(
         self.document, "additional_searchable_text"
     )
     self.assertEqual(additional_searchable_text, "trash")
示例#32
0
    def test_media_viewlet(self):
        keywords = ['album-a-la-une']
        view = getMultiAdapter((self.portal, self.request),
                               name='media_activation')
        # create video collection used to viewlet
        view.enable_media()
        album_collection = self.portal.albums.index
        query = [
            {
                'i': 'hiddenTags',
                'o': 'plone.app.querystring.operation.selection.is',
                'v': keywords
            },
        ]

        # Set hiddenTags and leadimage behaviors
        add_behavior('Folder', 'cpskin.core.behaviors.metadata.IHiddenTags')
        add_behavior('Folder',
                     'plone.app.contenttypes.behaviors.leadimage.ILeadImage')

        album_collection.query = query
        album = api.content.create(container=self.portal,
                                   type='Folder',
                                   id='testalbum')

        # getting viewlet
        view = BrowserView(self.portal, self.request)
        manager_name = 'plone.belowcontent'
        manager = queryMultiAdapter((self.portal, self.request, view),
                                    IViewletManager,
                                    manager_name,
                                    default=None)
        self.assertIsNotNone(manager)
        manager.update()

        my_viewlet = [
            v for v in manager.viewlets if v.__name__ == 'cpskin.media'
        ]
        self.assertEqual(len(my_viewlet), 1)
        media_viewlet = my_viewlet[0]

        self.assertTrue(media_viewlet.available())
        self.assertEqual(
            media_viewlet.get_albums_collection().getPhysicalPath(),
            self.portal.albums.index.getPhysicalPath())
        self.assertEqual(len(media_viewlet.get_albums()), 0)

        # Set lead image to album folder
        add_leadimage_from_file(album, 'cpskinlogo.png')
        add_keyword(album, 'hiddenTags', keywords)
        self.assertEqual(len(media_viewlet.get_albums()), 1)
示例#33
0
    def test_media_viewlet(self):
        keywords = ['album-a-la-une']
        view = getMultiAdapter(
            (self.portal, self.request), name='media_activation')
        # create video collection used to viewlet
        view.enable_media()
        album_collection = self.portal.albums.index
        query = [
            {
                'i': 'hiddenTags',
                'o': 'plone.app.querystring.operation.selection.is',
                'v': keywords
            },
        ]

        # Set hiddenTags and leadimage behaviors
        add_behavior('Folder', 'cpskin.core.behaviors.metadata.IHiddenTags')
        add_behavior(
            'Folder',
            'plone.app.contenttypes.behaviors.leadimage.ILeadImage')

        album_collection.query = query
        album = api.content.create(
            container=self.portal, type='Folder', id='testalbum')

        # getting viewlet
        view = BrowserView(self.portal, self.request)
        manager_name = 'plone.belowcontent'
        manager = queryMultiAdapter(
            (self.portal, self.request, view),
            IViewletManager,
            manager_name,
            default=None)
        self.assertIsNotNone(manager)
        manager.update()

        my_viewlet = [
            v for v in manager.viewlets if v.__name__ == 'cpskin.media']
        self.assertEqual(len(my_viewlet), 1)
        media_viewlet = my_viewlet[0]

        self.assertTrue(media_viewlet.available())
        self.assertEqual(
            media_viewlet.get_albums_collection().getPhysicalPath(),
            self.portal.albums.index.getPhysicalPath())
        self.assertEqual(len(media_viewlet.get_albums()), 0)

        # Set lead image to album folder
        add_leadimage_from_file(album, 'cpskinlogo.png')
        add_keyword(album, 'hiddenTags', keywords)
        self.assertEqual(len(media_viewlet.get_albums()), 1)
示例#34
0
def modified_event(obj, event):
    type_name = obj.id
    if type_name == 'Event':
        pae_behaviors = [
            'plone.app.event.dx.behaviors.IEventAttendees',
            'plone.app.event.dx.behaviors.IEventLocation',
            'plone.app.event.dx.behaviors.IEventContact'
        ]
        if 'cpskin.agenda.behaviors.related_contacts.IRelatedContacts' in obj.behaviors:  # noqa
            for pae_behavior in pae_behaviors:
                remove_behavior(type_name, pae_behavior)
        else:
            for pae_behavior in pae_behaviors:
                add_behavior(type_name, pae_behavior)
示例#35
0
def modified_event(obj, event):
    type_name = obj.id
    if type_name == 'Event':
        pae_behaviors = [
            'plone.app.event.dx.behaviors.IEventAttendees',
            'plone.app.event.dx.behaviors.IEventLocation',
            'plone.app.event.dx.behaviors.IEventContact'
        ]
        if 'cpskin.agenda.behaviors.related_contacts.IRelatedContacts' in obj.behaviors:  # noqa
            for pae_behavior in pae_behaviors:
                remove_behavior(type_name, pae_behavior)
        else:
            for pae_behavior in pae_behaviors:
                add_behavior(type_name, pae_behavior)
示例#36
0
    def test_geo_types_vocabulary(self):
        name = 'cpskin.core.vocabularies.geo_types'
        factory = getUtility(IVocabularyFactory, name)
        vocabulary = factory(self.portal)
        keys = vocabulary.by_value.keys()
        self.assertEqual(len(keys), 0)
        add_behavior('Document', ICoordinates.__identifier__)

        vocabulary = factory(self.portal)
        keys = vocabulary.by_value.keys()
        self.assertEqual(len(keys), 1)
        self.assertIn(u'Document', keys)

        remove_behavior('Document', ICoordinates.__identifier__)
示例#37
0
def enable_directory_versioning(context):
    add_behavior("directory", IVersionable.__identifier__)
    add_behavior("organization", IVersionable.__identifier__)
    add_behavior("person", IVersionable.__identifier__)
    add_behavior("position", IVersionable.__identifier__)
    context.runImportStepFromProfile("profile-cpskin.core:default", "repositorytool")
    context.runImportStepFromProfile("profile-cpskin.core:default", "difftool")
示例#38
0
    def test_folderview_event_category(self):
        applyProfile(self.portal, 'collective.taxonomy:default')
        add_behavior('Collection', ICpskinIndexViewSettings.__identifier__)

        utility = queryUtility(ITaxonomy, name='collective.taxonomy.test')
        collection = api.content.create(container=self.folder,
                                        type='Collection',
                                        id='collection')
        collection.taxonomy_category = 'taxonomy_test'
        collection.reindexObject()

        taxonomy_test = schema.Set(
            title=u'taxonomy_test',
            description=u'taxonomy description schema',
            required=False,
            value_type=schema.Choice(vocabulary=u'collective.taxonomy.test'),
        )
        portal_types = api.portal.get_tool('portal_types')
        fti = portal_types.get('Event')
        event_schema = fti.lookupSchema()
        schemaeditor = IEditableSchema(event_schema)
        schemaeditor.addField(taxonomy_test, name='taxonomy_test')
        notify(ObjectAddedEvent(taxonomy_test, event_schema))
        notify(FieldAddedEvent(fti, taxonomy_test))
        event = api.content.create(container=self.folder,
                                   type='Event',
                                   id='testevent')
        simple_tax = [val for val in utility.data['en'].values()]
        event.taxonomy_test = set(simple_tax[0])

        view = getMultiAdapter((self.portal, self.portal.REQUEST),
                               name='folderview')

        see_categories = view.see_categories(collection)
        self.assertTrue(see_categories)
        collection.taxonomy_category = ''
        see_categories = view.see_categories(collection)
        self.assertFalse(see_categories)
        collection.taxonomy_category = 'taxonomy_test'
        categories = view.get_categories(collection, event)
        self.assertEqual(categories, 'Information Science')

        event.taxonomy_test = set(simple_tax[0:2])
        categories = view.get_categories(collection, event)
        self.assertEqual(categories, 'Book Collecting, Information Science')

        event.taxonomy_test = set()
        categories = view.get_categories(collection, event)
        self.assertEqual(categories, '')
示例#39
0
 def setUpPloneSite(self, portal):
     portal.portal_workflow.setDefaultChain('simple_publication_workflow')
     # applyProfile(portal, 'plone.app.contenttypes:plone-content')
     applyProfile(portal, 'cpskin.core:testing')
     richtextvalue = RichTextValue(u'Footer static custom content',
                                   'text/plain', 'text/html')
     footer_static = portal['footer-static']
     footer_static.text = richtextvalue
     add_behavior('Document', 'cpskin.core.behaviors.metadata.IHiddenTags')
     add_behavior('News Item', 'collective.sticky.behavior.ISticky')
     googleapi = 'collective.geo.settings.interfaces.IGeoSettings.googleapi'
     api.portal.set_registry_record(
         googleapi, u'AIzaSyChlyBRkPYJvny6t0mRqawQtQao2cJBvaA')
     fti = api.portal.get_tool('portal_types')['Plone Site']
     fti.allowed_content_types = fti.allowed_content_types + ('directory', )
示例#40
0
 def test_event_geo_contents_view(self):
     add_behavior('Event', ICoordinates.__identifier__)
     event = api.content.create(container=self.folder,
                                type='Event', title='document')
     event.location = 'Rue Léon Morel, 1 5032 Isnes'
     form = getMultiAdapter(
         (self.portal, self.portal.REQUEST), name='set-geo-contents-form')
     form.request.form = {'form.widgets.content_types': [u'Event']}
     form.update()
     data, errors = form.extractData()
     self.assertEqual(len(errors), 0)
     coord = ICoordinates(event).coordinates
     self.assertFalse(coord.startswith('POINT '))
     form.handleApply(form, 'Ok')
     coord = ICoordinates(event).coordinates
     self.assertTrue(coord.startswith('POINT '))
示例#41
0
 def test_hidden_tags_vocabulary(self):
     name = 'cpskin.core.vocabularies.hiddenTags'
     factory = getUtility(IVocabularyFactory, name)
     vocabulary = factory(self.portal)
     keys = vocabulary.by_value.keys()
     self.assertEqual(keys, [u'a-la-une', u'homepage'])
     add_behavior('Document', IHiddenTags.__identifier__)
     setRoles(self.portal, TEST_USER_ID, ['Manager'])
     api.content.create(container=self.portal,
                        type='Document', title='document')
     document = self.portal.document
     document.hiddenTags = [u'mot clé caché']
     document.reindexObject()
     vocabulary = factory(self.portal)
     keys = vocabulary.by_value.keys()
     self.assertEqual(
         keys, [u'mot cl\xe9 cach\xe9', u'a-la-une', u'homepage'])
示例#42
0
 def test_event_geo_contents_view(self):
     add_behavior('Event', ICoordinates.__identifier__)
     event = api.content.create(container=self.folder,
                                type='Event',
                                title='document')
     event.location = 'Rue Léon Morel, 1 5032 Isnes'
     form = getMultiAdapter((self.portal, self.portal.REQUEST),
                            name='set-geo-contents-form')
     form.request.form = {'form.widgets.content_types': [u'Event']}
     form.update()
     data, errors = form.extractData()
     self.assertEqual(len(errors), 0)
     coord = ICoordinates(event).coordinates
     self.assertFalse(coord.startswith('POINT '))
     form.handleApply(form, 'Ok')
     coord = ICoordinates(event).coordinates
     self.assertTrue(coord.startswith('POINT '))
示例#43
0
    def test_cpskin_event_feed_item(self):
        folder = event = api.content.create(self.portal, 'Folder', 'myfolder')
        add_behavior('Event', IRelatedContacts.__identifier__)
        event = api.content.create(container=folder,
                                   type='Event',
                                   id='myevent')
        # add some contacts
        applyProfile(self.portal, 'collective.contact.core:default')
        add_behavior('organization', ICoordinates.__identifier__)
        directory = api.content.create(container=self.portal,
                                       type='directory',
                                       id='directory')
        organization = api.content.create(container=directory,
                                          type='organization',
                                          id='organization')
        organization.title = u'IMIO'
        organization.street = u'Rue Léon Morel'
        organization.number = u'1'
        organization.zip_code = u'5032'
        organization.city = u'Isnes'
        organization.use_parent_address = False
        # set related contact
        intids = getUtility(IIntIds)
        to_id = intids.getId(organization)
        rv = RelationValue(to_id)
        event.location = rv
        notify(ObjectModifiedEvent(event))
        event.reindexObject()
        # set syndication
        applyProfile(self.portal, 'collective.atomrss:default')
        default_enabled_key = 'Products.CMFPlone.interfaces.syndication.ISiteSyndicationSettings.default_enabled'  # noqa
        api.portal.set_registry_record(default_enabled_key, True)
        request = folder.REQUEST

        alsoProvides(request, ICollectiveAtomrssLayer)

        _metadata = PersistentDict()
        _metadata['render_body'] = True
        annotations = IAnnotations(folder)
        annotations[FEED_SETTINGS_KEY] = _metadata
        view = api.content.get_view(name='atom.xml',
                                    context=folder,
                                    request=request)
        self.assertTrue(u'IMIO<br />Rue L\xe9on Morel, 1<br />5032 Isnes'
                        in view.index())  # noqa
示例#44
0
    def test_cpskin_event_feed_item(self):
        folder = event = api.content.create(self.portal, 'Folder', 'myfolder')
        add_behavior('Event', IRelatedContacts.__identifier__)
        event = api.content.create(
            container=folder,
            type='Event',
            id='myevent'
        )
        # add some contacts
        applyProfile(self.portal, 'collective.contact.core:default')
        add_behavior('organization', ICoordinates.__identifier__)
        directory = api.content.create(
            container=self.portal, type='directory', id='directory')
        organization = api.content.create(
            container=directory, type='organization', id='organization')
        organization.title = u'IMIO'
        organization.street = u'Rue Léon Morel'
        organization.number = u'1'
        organization.zip_code = u'5032'
        organization.city = u'Isnes'
        organization.use_parent_address = False
        # set related contact
        intids = getUtility(IIntIds)
        to_id = intids.getId(organization)
        rv = RelationValue(to_id)
        event.location = rv
        notify(ObjectModifiedEvent(event))
        event.reindexObject()
        # set syndication
        applyProfile(self.portal, 'collective.atomrss:default')
        default_enabled_key = 'Products.CMFPlone.interfaces.syndication.ISiteSyndicationSettings.default_enabled'  # noqa
        api.portal.set_registry_record(default_enabled_key, True)
        request = folder.REQUEST

        alsoProvides(request, ICollectiveAtomrssLayer)

        _metadata = PersistentDict()
        _metadata['render_body'] = True
        annotations = IAnnotations(folder)
        annotations[FEED_SETTINGS_KEY] = _metadata
        view = api.content.get_view(
            name='atom.xml',
            context=folder,
            request=request)
        self.assertTrue(u'IMIO<br />Rue L\xe9on Morel, 1<br />5032 Isnes' in view.index())  # noqa
示例#45
0
 def test_modified_orga_events(self):
     # add some contacts
     applyProfile(self.portal, 'collective.contact.core:default')
     add_behavior('organization', ICoordinates.__identifier__)
     directory = api.content.create(
         container=self.portal, type='directory', id='directory')
     orga = api.content.create(
         container=directory, type='organization', id='orga')
     orga.use_parent_address = False
     orga.street = u'Rue Léon Morel'
     orga.number = u'1'
     # notify(ObjectAddedEvent(orga))
     coord = ICoordinates(orga).coordinates
     self.assertFalse(coord.startswith('POINT '))
     orga.zip_code = u'5032'
     orga.city = u'Isnes'
     notify(ObjectModifiedEvent(orga))
     coord = ICoordinates(orga).coordinates
     self.assertTrue(coord.startswith('POINT '))
示例#46
0
 def test_cpskin_navigation_with_leadimage_view(self):
     applyProfile(self.portal, 'cpskin.workflow:default')
     add_behavior('Folder',
                  'plone.app.contenttypes.behaviors.leadimage.ILeadImage')
     self.portal.portal_workflow.setDefaultChain('cpskin_workflow')
     subfolder = api.content.create(self.folder, 'Folder', 'subfolder')
     view = api.content.get_view(
         name='cpskin_navigation_view_with_leadimage',
         context=self.folder,
         request=self.folder.REQUEST)
     self.assertEqual(0, len(view.menus()))
     api.content.transition(obj=subfolder, transition='publish_and_show')
     self.assertEqual(1, len(view.menus()))
     brain = api.content.find(UID=IUUID(subfolder))[0]
     self.assertFalse(view.image(brain))
     add_leadimage_from_file(subfolder, 'visuel.png')
     self.assertTrue(
         view.image(brain).startswith(
             u'http://nohost/plone/folder/subfolder/@@images'))
示例#47
0
    def test_folderview_without_keyword_homepage(self):
        add_behavior('News Item', 'cpskin.core.behaviors.metadata.IHiddenTags')
        view = getMultiAdapter((self.portal, self.request), name='folderview')
        result = view.getResults(self.portal.actualites.actualites)
        self.assertTrue(result is None)

        # Adding content for fill collection
        news = api.content.create(container=self.portal.actualites,
                                  type='News Item',
                                  id='testnewsitem')
        api.content.transition(obj=news, transition='publish')
        result = view.getResults(self.portal.actualites.actualites)
        self.assertEqual(len(result.get('standard-results', 0)), 1)

        add_keyword(news, 'hiddenTags', ['homepage'])
        add_keyword(news, 'hiddenTags', ['non-homepage'])

        result = view.getResults(self.portal.actualites.actualites)
        self.assertEqual(len(result.get('standard-results', 0)), 1)
示例#48
0
 def setUpPloneSite(self, portal):
     portal.portal_workflow.setDefaultChain('simple_publication_workflow')
     # applyProfile(portal, 'plone.app.contenttypes:plone-content')
     applyProfile(portal, 'cpskin.core:testing')
     richtextvalue = RichTextValue(
         u'Footer static custom content',
         'text/plain',
         'text/html'
     )
     footer_static = portal['footer-static']
     footer_static.text = richtextvalue
     add_behavior('Document', 'cpskin.core.behaviors.metadata.IHiddenTags')
     add_behavior('News Item', 'collective.sticky.behavior.ISticky')
     googleapi = 'collective.geo.settings.interfaces.IGeoSettings.googleapi'
     api.portal.set_registry_record(
         googleapi,
         u'AIzaSyChlyBRkPYJvny6t0mRqawQtQao2cJBvaA')
     fti = api.portal.get_tool('portal_types')['Plone Site']
     fti.allowed_content_types = fti.allowed_content_types + ('directory',)
示例#49
0
    def test_folderview_old_new_template(self):
        add_behavior(
            'Collection',
            'cpskin.core.behaviors.indexview.ICpskinIndexViewSettings')
        configure_folderviews(self.portal)
        news = api.content.create(container=self.folder,
                                  type='News Item',
                                  id='testnewsitem')
        api.content.transition(obj=news, transition='publish')
        collection = self.portal.actualites.actualites
        view = getMultiAdapter((self.portal, self.request), name='folderview')
        self.assertEqual(collection.collection_image_scale, 'collection')
        add_leadimage_from_file(news, 'visuel.png')
        scale = view.collection_image_scale(collection, news)
        self.assertTrue('height="116"' in scale)

        collection.use_new_template = True
        scale = view.collection_image_scale(collection, news)
        self.assertEqual(scale.height, 116)
        self.assertEqual(scale.width, 77)
示例#50
0
    def test_folderview_without_keyword_homepage(self):
        add_behavior('News Item', 'cpskin.core.behaviors.metadata.IHiddenTags')
        view = getMultiAdapter((self.portal, self.request), name='folderview')
        result = view.getResults(self.portal.actualites.actualites)
        self.assertTrue(result is None)

        # Adding content for fill collection
        news = api.content.create(
            container=self.portal.actualites,
            type='News Item',
            id='testnewsitem')
        api.content.transition(obj=news, transition='publish')
        result = view.getResults(self.portal.actualites.actualites)
        self.assertEqual(len(result.get('standard-results', 0)), 1)

        add_keyword(news, 'hiddenTags', ['homepage'])
        add_keyword(news, 'hiddenTags', ['non-homepage'])

        result = view.getResults(self.portal.actualites.actualites)
        self.assertEqual(len(result.get('standard-results', 0)), 1)
示例#51
0
 def test_cpskin_navigation_with_leadimage_view(self):
     applyProfile(self.portal, 'cpskin.workflow:default')
     add_behavior(
         'Folder',
         'plone.app.contenttypes.behaviors.leadimage.ILeadImage')
     self.portal.portal_workflow.setDefaultChain('cpskin_workflow')
     subfolder = api.content.create(self.folder, 'Folder', 'subfolder')
     view = api.content.get_view(
         name='cpskin_navigation_view_with_leadimage',
         context=self.folder,
         request=self.folder.REQUEST)
     self.assertEqual(0, len(view.menus()))
     api.content.transition(obj=subfolder, transition='publish_and_show')
     self.assertEqual(1, len(view.menus()))
     brain = api.content.find(UID=IUUID(subfolder))[0]
     self.assertFalse(view.image(brain))
     add_leadimage_from_file(subfolder, 'visuel.png')
     self.assertTrue(view.image(brain).startswith(
         u'http://nohost/plone/folder/subfolder/@@images'
     ))
示例#52
0
def installCore(context):
    if context.readDataFile('cpskin.core-default.txt') is None:
        return

    logger.info('Installing')
    portal = api.portal.get()

    # Rename events and news
    ChangeCollectionsIds(portal)

    # Add the MaildropHost if possible
    addMaildropHost(portal)

    # Add catalog indexes
    addCatalogIndexes(portal)

    # Create default banner image
    addImageFromFile(portal, 'banner.jpg')

    # Create default visuel image
    addImageFromFile(portal, 'visuel.png')

    # Create default logo
    addImageFromFile(portal, 'cpskinlogo.png')

    add_behavior('Collection', ICpskinIndexViewSettings.__identifier__)
    add_behavior('Event', ICpskinEventViewSettings.__identifier__)
    add_behavior('organization', IOrganizationImages.__identifier__)
    add_behavior('directory', ICpskinDirectoryViewSettings.__identifier__)

    # Create footer static page
    footer_name = 'footer-static'
    if not portal.hasObject(footer_name):
        footer = api.content.create(type='Document',
                                    title=footer_name,
                                    container=portal)
        footer.setTitle(footer_name)

    configCollectiveQucikupload(portal)

    addLoadPageMenuToRegistry()
    addAutoPlaySliderToRegistry()
    addSliderTimerToRegistry()
    addCityNameToRegistry()
    addSubMenuPersistenceToRegistry()
    # addSliderTypeToRegistry()
    set_googleapi_key()
    upgrade_front_page()
    order_portaltop_viewlets()
    add_other_xhtml_valid_tags()
    add_default_taxonomies()
示例#53
0
    def test_bad_orga_geo_contents_view(self):
        # add some contacts
        applyProfile(self.portal, 'collective.contact.core:default')
        add_behavior('person', ICoordinates.__identifier__)
        directory = api.content.create(container=self.portal,
                                       type='directory',
                                       id='directory')
        person = api.content.create(container=directory,
                                    type='person',
                                    id='person')

        form = getMultiAdapter((self.portal, self.portal.REQUEST),
                               name='set-geo-contents-form')
        form.request.form = {'form.widgets.content_types': [u'person']}
        form.update()
        form.handleApply(form, 'Ok')
        messages = IStatusMessage(
            self.portal.REQUEST).showStatusMessages()  # noqa
        self.assertEqual(
            messages[0].message,
            u'No address for http://nohost/plone/directory/person')  # noqa
        self.assertEqual(messages[1].message, u'0 person are updated')
        person.street = u'Rue de l\'hôtel de ville'
        person.number = u'34'
        person.zip_code = u'5190'
        person.city = u'Mornimont'

        form = getMultiAdapter((self.portal, self.portal.REQUEST),
                               name='set-geo-contents-form')
        form.request.form = {'form.widgets.content_types': [u'person']}
        form.update()

        coord = ICoordinates(person).coordinates
        self.assertFalse(coord.startswith('POINT '))
        form.handleApply(form, 'Ok')
        messages = IStatusMessage(
            self.portal.REQUEST).showStatusMessages()  # noqa
        self.assertEqual(messages[0].message, u'1 person are updated')
        coord = ICoordinates(person).coordinates
        self.assertTrue(coord.startswith('POINT '))
示例#54
0
    def test_only_one_attendees_field(self):
        fti = queryUtility(IDexterityFTI, name='Event')
        event_behaviors = ['plone.app.event.dx.behaviors.IEventAttendees',
                           'plone.app.event.dx.behaviors.IEventLocation',
                           'plone.app.event.dx.behaviors.IEventContact'
                           ]

        behaviors = list(fti.behaviors)

        for event_behavior in event_behaviors:
            self.assertIn(event_behavior, behaviors)

        add_behavior('Event', IRelatedContacts.__identifier__)

        behaviors = list(fti.behaviors)
        for event_behavior in event_behaviors:
            self.assertNotIn(event_behavior, behaviors)

        remove_behavior('Event', IRelatedContacts.__identifier__)

        behaviors = list(fti.behaviors)
        for event_behavior in event_behaviors:
            self.assertIn(event_behavior, behaviors)
示例#55
0
    def test_bad_orga_geo_contents_view(self):
        # add some contacts
        applyProfile(self.portal, 'collective.contact.core:default')
        add_behavior('person', ICoordinates.__identifier__)
        directory = api.content.create(
            container=self.portal, type='directory', id='directory')
        person = api.content.create(
            container=directory, type='person', id='person')

        form = getMultiAdapter(
            (self.portal, self.portal.REQUEST), name='set-geo-contents-form')
        form.request.form = {'form.widgets.content_types': [u'person']}
        form.update()
        form.handleApply(form, 'Ok')
        messages = IStatusMessage(self.portal.REQUEST).showStatusMessages()  # noqa
        self.assertEqual(
            messages[0].message,
            u'No address for http://nohost/plone/directory/person')  # noqa
        self.assertEqual(messages[1].message, u'0 person are updated')
        person.street = u'Rue de l\'hôtel de ville'
        person.number = u'34'
        person.zip_code = u'5190'
        person.city = u'Mornimont'

        form = getMultiAdapter(
            (self.portal, self.portal.REQUEST), name='set-geo-contents-form')
        form.request.form = {'form.widgets.content_types': [u'person']}
        form.update()

        coord = ICoordinates(person).coordinates
        self.assertFalse(coord.startswith('POINT '))
        form.handleApply(form, 'Ok')
        messages = IStatusMessage(self.portal.REQUEST).showStatusMessages()  # noqa
        self.assertEqual(messages[0].message, u'1 person are updated')
        coord = ICoordinates(person).coordinates
        self.assertTrue(coord.startswith('POINT '))
示例#56
0
    def test_only_one_attendees_field(self):
        fti = queryUtility(IDexterityFTI, name='Event')
        event_behaviors = [
            'plone.app.event.dx.behaviors.IEventAttendees',
            'plone.app.event.dx.behaviors.IEventLocation',
            'plone.app.event.dx.behaviors.IEventContact'
        ]

        behaviors = list(fti.behaviors)

        for event_behavior in event_behaviors:
            self.assertIn(event_behavior, behaviors)

        add_behavior('Event', IRelatedContacts.__identifier__)

        behaviors = list(fti.behaviors)
        for event_behavior in event_behaviors:
            self.assertNotIn(event_behavior, behaviors)

        remove_behavior('Event', IRelatedContacts.__identifier__)

        behaviors = list(fti.behaviors)
        for event_behavior in event_behaviors:
            self.assertIn(event_behavior, behaviors)
示例#57
0
def upgrade_add_booking_behavior(context):
    portal_types = api.portal.get_tool(name='portal_types')
    event_type = portal_types.get('Event')
    fields = event_type.lookupSchema().names()

    if ('tarifs' not in fields and 'reservation' not in fields):
        # This upgrade step is specific to Liege, where those fields have been
        # added TTW.
        return

    add_behavior('Event', IBooking.__identifier__)
    for brain in api.content.find(portal_type='Event'):
        obj = brain.getObject()
        if getattr(obj, 'tarifs') is not None:
            obj.booking_price = getattr(obj, 'tarifs')
        if getattr(obj, 'reservation') is not None:
            has_booking = getattr(obj, 'reservation')
            if has_booking:
                obj.booking_type = 'mandatory'
            else:
                obj.booking_type = 'no_booking'
    schema = IEditableSchema(event_type.lookupSchema())
    schema.removeField('tarifs')
    schema.removeField('reservation')