Beispiel #1
0
    def _duplicateevents(self):

        import datetime
        from p4a.calendar import interfaces
        events = getattr(self, '_dup_cached_events', None)
        if events is not None:
            return events

        if not hasattr(self, 'context'):
            self._dup_cached_events = []
            return self._dup_cached_events

        default = self.default_day

        start = datetime.datetime(default.year, default.month, 1, 0, 0)

        if default.month < 12:
            end = datetime.datetime(default.year, default.month + 1, 1, 23, 59)
            end -= datetime.timedelta(days=1)
        elif default.month == 12:
            end = datetime.datetime(default.year, default.month, 31, 23, 59)

        provider = interfaces.IEventProvider(self.context)

        self._dup_cached_events = provider.gather_events(
            start, end, **self.request.form)
        return self._dup_cached_events
Beispiel #2
0
    def _getEventList(self, start=None, stop=None, reverse=False):
        provider = interfaces.IEventProvider(self.context)
        now = datetime.datetime.now()
        events = list(
            provider.gather_events(start=start, stop=stop,
                                   **self.request.form))
        events.sort()
        # If this is an archive, revert the event list.
        if reverse:
            events.reverse()
        months = []
        month_info = []
        old_month_year = None
        for event in events:
            start = event.start
            month = str(start.month)
            year = str(start.year)
            month_year = year + month
            if month_year != old_month_year:
                old_month_year = month_year
                if month_info:
                    months.append(month_info)
                month_info = {
                    'month': start.month,
                    'year': start.year,
                    'month_name': start.strftime("%B"),
                    'events': []
                }
            event_dict = {
                'event': event,
                'day': start.day,
                'start': start,
                'end': event.end,
                'location': event.location,
                'title': event.title,
                'description': event.description,
                'url': event.local_url,
            }
            month_info['events'].append(event_dict)

        if month_info:
            months.append(month_info)

        return months
Beispiel #3
0
 def getTags(self):
     from p4a.calendar import interfaces
     from ubify.cyninv2theme import getTagsAndTagsCount
     tags = []
     provider = interfaces.IEventProvider(self.context)
     now = datetime.datetime.now()
     events = []
     if self.context.REQUEST.URL.endswith('upcomingEvents'):
         events = list(
             provider.gather_events(start=now,
                                    stop=None,
                                    **self.request.form))
     else:
         events = list(
             provider.gather_events(start=None,
                                    stop=now,
                                    **self.request.form))
     tags = getTagsAndTagsCount(events)
     return tags
Beispiel #4
0
 def event_creation_link(self, start=None, stop=None):
     provider = interfaces.IEventProvider(self.context)
     return provider.event_creation_link(start, stop)