コード例 #1
0
ファイル: recurrence.py プロジェクト: gyst/plone.app.event
 def __new__(cls, context, request):
     parent = aq_parent(context)
     if IATEvent.providedBy(parent):
         return ATImageScaling(parent, request)
     elif IDXEvent.providedBy(parent):
         return DXImageScaling(parent, request)
     return None
コード例 #2
0
def ticket_title_generator(obj):
    """Generate a title for the ticket, also using event information.
    """

    event = obj
    ret = {
        'title': obj.title, 'eventtitle': '', 'eventstart': '', 'eventend': ''
    }

    if ITicketOccurrence.providedBy(event):
        event = aq_parent(aq_parent(event))
        # Traverse to the Occurrence object
        if IATEvent.providedBy(event):
            # get the request out of thin air to be able to publishTraverse to
            # the transient Occurrence object.
            traverser = OccTravAT(event, getRequest())
        elif IDXEvent.providedBy(event):
            # TODO
            traverser = OccTravDX(event, getRequest())
        else:
            raise NotImplementedError(
                u"There is no event occurrence traverser implementation for "
                u"this kind of object."
            )
        try:
            event = traverser.publishTraverse(getRequest(), obj.id)
        except KeyError:
            # Maybe the ticket occurrence isn't valid anymore because the
            # event occurence doesn't exist anymore.
            # Just ignore that case.
            return ret

    elif ITicket.providedBy(event):
        event = aq_parent(event)

    if IEvent.providedBy(event) or IOccurrence.providedBy(event):
        acc = IEventAccessor(event)
        lstart = ulocalized_time(
            DT(acc.start),
            long_format=True,
            context=event
        )
        lend = ulocalized_time(
            DT(acc.start),
            long_format=True,
            context=event
        )
        # XXX: no unicode, store as utf-8 encoded string instead
        ret = dict(
            title=u'%s - %s (%s - %s)' % (
                safe_unicode(acc.title),
                safe_unicode(obj.title),
                lstart,
                lend,
            ),
            eventtitle=acc.title,
            eventstart=acc.start,
            eventend=acc.end,
        )
    return ret
コード例 #3
0
ファイル: recurrence.py プロジェクト: FHNW/plone.app.event
 def __new__(cls, context, request):
     parent = aq_parent(context)
     if IATEvent.providedBy(parent):
         return ATImageScaling(parent, request)
     elif IDXEvent.providedBy(parent):
         return DXImageScaling(parent, request)
     return None
コード例 #4
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
コード例 #5
0
 def test_factory(self):
     fti = queryUtility(IDexterityFTI, name='plone.app.event.dx.event')
     factory = fti.factory
     new_object = createObject(factory)
     self.failUnless(IDXEvent.providedBy(new_object))
     self.failUnless(IDXEventRecurrence.providedBy(new_object))
     self.failUnless(IDXEventLocation.providedBy(new_object))
     self.failUnless(IDXEventAttendees.providedBy(new_object))
     self.failUnless(IDXEventContact.providedBy(new_object))
コード例 #6
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))
コード例 #7
0
def ticket_title_generator(obj):
    """Generate a title for the ticket, also using event information.
    """

    event = obj
    ret = {
        'title': obj.title,
        'eventtitle': '',
        'eventstart': '',
        'eventend': ''
    }

    if ITicketOccurrence.providedBy(event):
        event = aq_parent(aq_parent(event))
        # Traverse to the Occurrence object
        if IATEvent.providedBy(event):
            # get the request out of thin air to be able to publishTraverse to
            # the transient Occurrence object.
            traverser = OccTravAT(event, getRequest())
        elif IDXEvent.providedBy(event):
            # TODO
            traverser = OccTravDX(event, getRequest())
        else:
            raise NotImplementedError(
                u"There is no event occurrence traverser implementation for "
                u"this kind of object.")
        try:
            event = traverser.publishTraverse(getRequest(), obj.id)
        except KeyError:
            # Maybe the ticket occurrence isn't valid anymore because the
            # event occurence doesn't exist anymore.
            # Just ignore that case.
            return ret

    elif ITicket.providedBy(event):
        event = aq_parent(event)

    if IEvent.providedBy(event) or IOccurrence.providedBy(event):
        acc = IEventAccessor(event)
        lstart = ulocalized_time(DT(acc.start),
                                 long_format=True,
                                 context=event)
        lend = ulocalized_time(DT(acc.start), long_format=True, context=event)
        # XXX: no unicode, store as utf-8 encoded string instead
        ret = dict(
            title=u'%s - %s (%s - %s)' % (
                safe_unicode(acc.title),
                safe_unicode(obj.title),
                lstart,
                lend,
            ),
            eventtitle=acc.title,
            eventstart=acc.start,
            eventend=acc.end,
        )
    return ret
コード例 #8
0
 def test_adding(self):
     self.portal.invokeFactory('plone.app.event.dx.event', 'event1',
             start=datetime(2011,11,11,11,00),
             end=datetime(2011,11,11,12,00),
             timezone='CET',
             whole_day=False)
     e1 = self.portal['event1']
     self.failUnless(IDXEvent.providedBy(e1))
     self.failUnless(IDXEventRecurrence.providedBy(e1))
     self.failUnless(IDXEventLocation.providedBy(e1))
     self.failUnless(IDXEventAttendees.providedBy(e1))
     self.failUnless(IDXEventContact.providedBy(e1))
コード例 #9
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))
コード例 #10
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'])
コード例 #11
0
    def feeddata(self):
        header = cs.ICS_HEADER % dict(prodid=cs.PRODID)
        events = []
        for brain in self.events:
            obj = brain.getObject()
            event_data = ""

            if ICalendarSupport.providedBy(obj):
                event_data = obj.getICal()

            if PLONE_APP_EVENTS_AVAILABLE:
                if IDXEvent.providedBy(obj):
                    cal = construct_icalendar(obj, obj)
                    event = cal.subcomponents[0]
                    event_data = event.to_ical()

            events.append(event_data)

        return header + "".join(events) + cs.ICS_FOOTER
コード例 #12
0
 def setData(self, data, metadata):
     event = IDXEvent(self.context)
     event.start = data['start'].asdatetime()
     event.end = data['end'].asdatetime()
コード例 #13
0
 def setData(self, data, metadata):
     event = IDXEvent(self.context)
     event.start = data['start'].asdatetime()
     event.end = data['end'].asdatetime()
コード例 #14
0
 def getData(self):
     event = IDXEvent(self.context)
     return {'start': DateTime(event.start), 'end': DateTime(event.end)}
コード例 #15
0
ファイル: behaviors.py プロジェクト: g24at/g24.elements
 def is_event(self):
     return IDXEvent.providedBy(self.context)