Exemplo n.º 1
0
    def test_fix_interface_for_event(self):
        self.obj.portal_type = 'Event'
        self.catalog.reindexObject(self.obj)

        self.portal.restrictedTraverse('fix_base_classes')()

        self.assertTrue(IEvent.providedBy(self.obj))
Exemplo n.º 2
0
 def test_factory(self):
     fti = queryUtility(
         IDexterityFTI,
         name='Event'
     )
     factory = fti.factory
     new_object = createObject(factory)
     self.failUnless(IEvent.providedBy(new_object))
Exemplo n.º 3
0
def get_location(context):
    """Return the location, using our own field"""
    location = u""
    if IEvent.providedBy(context):
        data = IEventLocation(context)
        location = data.location
    elif IEventAccessor.providedBy(context):
        location = context.location
    return location
Exemplo n.º 4
0
    def test_migrate_atevent_to_dxevent(self):
        """Tests the custom migration by migrating a default type. It is not
        meant to be used this way but is a nice way to test the migrations.
        During this migration the event fti is already replaced by the dx one.
        """
        from DateTime import DateTime
        from plone.app.contenttypes.migration.migration import migrateCustomAT
        from plone.app.contenttypes.interfaces import IEvent

        # create an ATEvent
        self.portal.invokeFactory('Event', 'event')
        at_event = self.portal['event']

        # Date
        FORMAT = '%Y-%m-%d %H:%M'
        start = '2013-02-03 12:15'
        end = '2013-04-05 13:45'
        at_event.getField('startDate').set(at_event, DateTime(start))
        at_event.getField('endDate').set(at_event, DateTime(end))

        # Contact
        at_event.getField('contactPhone').set(at_event, '123456789')
        at_event.getField('contactEmail').set(at_event, '*****@*****.**')
        at_event.getField('contactName').set(at_event, u'Näme')

        # URL
        at_event.getField('eventUrl').set(at_event, 'http://www.plone.org')

        # Attendees
        at_event.getField('attendees').set(at_event, ('Yöu', 'Me'))

        # Text
        at_event.setText('Tütensuppe')
        at_event.setContentType('text/plain')

        oldTZ = os.environ.get('TZ', None)
        TZ = 'Asia/Tbilisi'
        os.environ['TZ'] = TZ
        timezone = pytz.timezone(TZ)

        qi = self.portal.portal_quickinstaller
        # install pac but only install Event
        qi.installProduct('plone.app.contenttypes',
                          profile='plone.app.contenttypes:default',
                          blacklistedSteps=['typeinfo'])
        installTypeIfNeeded('Event')
        fields_mapping = (
            {
                'AT_field_name': 'startDate',
                'AT_field_type': 'Products.Archetypes.Field.DateTimeField',
                'DX_field_name': 'start',
                'DX_field_type': 'Datetime',
            },
            {
                'AT_field_name': 'endDate',
                'AT_field_type': 'Products.Archetypes.Field.DateTimeField',
                'DX_field_name': 'end',
                'DX_field_type': 'Datetime',
            },
            {
                'AT_field_name': 'text',
                'AT_field_type': 'Products.Archetypes.Field.TextField',
                'DX_field_name': 'text',
                'DX_field_type': 'RichText',
            },
            {
                'AT_field_name': 'eventUrl',
                'AT_field_type': 'Products.Archetypes.Field.StringField',
                'DX_field_name': 'event_url',
                'DX_field_type': 'StringField',
            },
            {
                'AT_field_name': 'contactEmail',
                'AT_field_type': 'Products.Archetypes.Field.StringField',
                'DX_field_name': 'contact_email',
                'DX_field_type': 'StringField',
            },
            {
                'AT_field_name': 'contactName',
                'AT_field_type': 'Products.Archetypes.Field.StringField',
                'DX_field_name': 'contact_name',
                'DX_field_type': 'StringField',
            },
            {
                'AT_field_name': 'contactPhone',
                'AT_field_type': 'Products.Archetypes.Field.StringField',
                'DX_field_name': 'contact_phone',
                'DX_field_type': 'StringField',
            },
            {
                'AT_field_name': 'attendees',
                'AT_field_type': 'Products.Archetypes.Field.LinesField',
                'DX_field_name': 'attendees',
                'DX_field_type': 'Tuple',
            },
        )
        # migrate ATEvent to new default Event
        migrateCustomAT(fields_mapping, src_type='Event', dst_type='Event')
        dx_event = self.portal['event']
        self.assertTrue(IEvent.providedBy(dx_event))
        self.assertTrue(dx_event is not at_event)
        self.assertEqual(safe_unicode(at_event.getText()),
                         dx_event.text.output)
        self.assertEqual(at_event.eventUrl, dx_event.event_url)
        self.assertEqual(at_event.contactEmail, dx_event.contact_email)
        self.assertEqual(at_event.contactName, dx_event.contact_name)
        self.assertEqual(at_event.contactPhone, dx_event.contact_phone)
        self.assertEqual(at_event.attendees, dx_event.attendees)
        self.assertEqual(dx_event.start,
                         timezone.localize(datetime.strptime(start, FORMAT)))
        self.assertEqual(dx_event.end,
                         timezone.localize(datetime.strptime(end, FORMAT)))
        if oldTZ:
            os.environ['TZ'] = oldTZ
        else:
            del os.environ['TZ']
 def test_ievent(self):
     self.assertTrue(IEvent.providedBy(self.compromisso))
    def test_migrate_atevent_to_dxevent(self):
        """Tests the custom migration by migrating a default type. It is not
        meant to be used this way but is a nice way to test the migrations.
        During this migration the event fti is already replaced by the dx one.
        """
        from DateTime import DateTime
        from plone.app.contenttypes.migration.migration import migrateCustomAT
        from plone.app.contenttypes.interfaces import IEvent

        # create an ATEvent
        self.portal.invokeFactory('Event', 'event')
        at_event = self.portal['event']

        # Date
        FORMAT = '%Y-%m-%d %H:%M'
        start = '2013-02-03 12:15'
        end = '2013-04-05 13:45'
        at_event.getField('startDate').set(at_event, DateTime(start))
        at_event.getField('endDate').set(at_event, DateTime(end))

        # Contact
        at_event.getField('contactPhone').set(at_event, '123456789')
        at_event.getField('contactEmail').set(at_event, '*****@*****.**')
        at_event.getField('contactName').set(at_event, u'Näme')

        # URL
        at_event.getField('eventUrl').set(at_event, 'http://www.plone.org')

        # Attendees
        at_event.getField('attendees').set(at_event, ('Yöu', 'Me'))

        # Text
        at_event.setText('Tütensuppe')
        at_event.setContentType('text/plain')

        oldTZ = os.environ.get('TZ', None)
        TZ = 'Asia/Tbilisi'
        os.environ['TZ'] = TZ
        timezone = pytz.timezone(TZ)

        qi = self.portal.portal_quickinstaller
        # install pac but only install Event
        qi.installProduct(
            'plone.app.contenttypes',
            profile='plone.app.contenttypes:default',
            blacklistedSteps=['typeinfo'])
        installTypeIfNeeded("Event")
        fields_mapping = (
            {'AT_field_name': 'startDate',
             'AT_field_type': 'Products.Archetypes.Field.DateTimeField',
             'DX_field_name': 'start',
             'DX_field_type': 'Datetime', },
            {'AT_field_name': 'endDate',
             'AT_field_type': 'Products.Archetypes.Field.DateTimeField',
             'DX_field_name': 'end',
             'DX_field_type': 'Datetime', },
            {'AT_field_name': 'text',
             'AT_field_type': 'Products.Archetypes.Field.TextField',
             'DX_field_name': 'text',
             'DX_field_type': 'RichText', },
            {'AT_field_name': 'eventUrl',
             'AT_field_type': 'Products.Archetypes.Field.StringField',
             'DX_field_name': 'event_url',
             'DX_field_type': 'StringField', },
            {'AT_field_name': 'contactEmail',
             'AT_field_type': 'Products.Archetypes.Field.StringField',
             'DX_field_name': 'contact_email',
             'DX_field_type': 'StringField', },
            {'AT_field_name': 'contactName',
             'AT_field_type': 'Products.Archetypes.Field.StringField',
             'DX_field_name': 'contact_name',
             'DX_field_type': 'StringField', },
            {'AT_field_name': 'contactPhone',
             'AT_field_type': 'Products.Archetypes.Field.StringField',
             'DX_field_name': 'contact_phone',
             'DX_field_type': 'StringField', },
            {'AT_field_name': 'attendees',
             'AT_field_type': 'Products.Archetypes.Field.LinesField',
             'DX_field_name': 'attendees',
             'DX_field_type': 'Tuple', },
        )
        # migrate ATEvent to new default Event
        migrateCustomAT(fields_mapping, src_type='Event', dst_type='Event')
        dx_event = self.portal['event']
        self.assertTrue(IEvent.providedBy(dx_event))
        self.assertTrue(dx_event is not at_event)
        self.assertEquals(safe_unicode(
            at_event.getText()), dx_event.text.output)
        self.assertEquals(at_event.eventUrl, dx_event.event_url)
        self.assertEquals(at_event.contactEmail, dx_event.contact_email)
        self.assertEquals(at_event.contactName, dx_event.contact_name)
        self.assertEquals(at_event.contactPhone, dx_event.contact_phone)
        self.assertEquals(at_event.attendees, dx_event.attendees)
        self.assertEquals(
            dx_event.start,
            timezone.localize(datetime.strptime(start, FORMAT)))
        self.assertEquals(
            dx_event.end, timezone.localize(datetime.strptime(end, FORMAT)))
        if oldTZ:
            os.environ['TZ'] = oldTZ
        else:
            del os.environ['TZ']
Exemplo n.º 7
0
 def test_adding(self):
     self.portal.invokeFactory(
         'Event',
         'doc1'
     )
     self.assertTrue(IEvent.providedBy(self.portal['doc1']))
Exemplo n.º 8
0
 def migrate(self):
     # Only migrate items using old Schema
     if IEvent.providedBy(self.old) and hasattr(self.old, 'start_date'):
         ContentMigrator.migrate(self)
 def test_ievent(self):
     self.assertTrue(IEvent.providedBy(self.compromisso))