Пример #1
0
    def get_location(self):
        """In case location is not of type basestring, it's propably a
        reference, which case we handle here.
        """
        context = self.context

        # Get the original location directly from the context, as in case of
        # reference, the accessor might return an string representing the
        # location instead of the referenced object.
        location = None
        if IATEvent.providedBy(context):
            location = context.getLocation()
        elif IDXEvent.providedBy(context):
            from plone.app.event.dx.behaviors import IEventLocation
            location = IEventLocation(context).location

        if location and not isinstance(location, basestring) and\
            hasattr(location, 'absolute_url') and\
            hasattr(location, 'Title'):
            # Then I'm a reference
            location = u'<a href="%s" title="%s">%s</a>' % (
                location.absolute_url(),
                self.data.location,  # A meaningful title, e.g. the address
                location.Title()
            )
        return location
Пример #2
0
 def test_factory(self):
     fti = queryUtility(IDexterityFTI, name='plone.app.event.dx.event')
     factory = fti.factory
     new_object = createObject(factory)
     self.assertTrue(IDXEvent.providedBy(new_object))
     self.assertTrue(IDXEventRecurrence.providedBy(new_object))
     self.assertTrue(IEventLocation.providedBy(new_object))
     self.assertTrue(IEventAttendees.providedBy(new_object))
     self.assertTrue(IEventContact.providedBy(new_object))
Пример #3
0
 def test_factory(self):
     fti = queryUtility(IDexterityFTI, name='plone.app.event.dx.event')
     factory = fti.factory
     new_object = createObject(factory)
     self.assertTrue(IDXEvent.providedBy(new_object))
     self.assertTrue(IDXEventRecurrence.providedBy(new_object))
     self.assertTrue(IEventLocation.providedBy(new_object))
     self.assertTrue(IEventAttendees.providedBy(new_object))
     self.assertTrue(IEventContact.providedBy(new_object))
Пример #4
0
 def test_adding(self):
     self.portal.invokeFactory(
         'plone.app.event.dx.event',
         'event1',
         start=datetime(2011, 11, 11, 11, 0),
         end=datetime(2011, 11, 11, 12, 0),
         timezone=TZNAME,
         whole_day=False
     )
     e1 = self.portal['event1']
     self.assertTrue(IDXEvent.providedBy(e1))
     self.assertTrue(IDXEventRecurrence.providedBy(e1))
     self.assertTrue(IEventLocation.providedBy(e1))
     self.assertTrue(IEventAttendees.providedBy(e1))
     self.assertTrue(IEventContact.providedBy(e1))
Пример #5
0
    def test_adding(self):
        self.portal.invokeFactory(
            'plone.app.event.dx.event',
            'event1',
            start=datetime(2011, 11, 11, 11, 0),
            end=datetime(2011, 11, 11, 12, 0),
            timezone=TZNAME,
            whole_day=False
        )
        e1 = self.portal['event1']
        self.assertTrue(IDXEvent.providedBy(e1))
        self.assertTrue(IDXEventRecurrence.providedBy(e1))
        self.assertTrue(IEventLocation.providedBy(e1))
        self.assertTrue(IEventAttendees.providedBy(e1))
        self.assertTrue(IEventContact.providedBy(e1))

        self.portal.manage_delObjects(['event1'])
Пример #6
0
def location(obj):
    try:
        adapted = IEventLocation(obj)
        return adapted.location
    except TypeError:
        return ""