Example #1
0
    def iter_events(self, start_date, users):
        start_date = start_date.replace(hour=0, minute=0, second=0, microsecond=0)
        for d in self.doc['data']:
            if not d['ls']: # seems to be validation state
                continue
            assert d['ls'] == 2

            user = users[d['u']]

            ev = BaseCalendarEvent()
            ev.timezone = 'Europe/Paris'
            ev.summary = user.name
            ev.status = STATUS.CONFIRMED
            ev.start_date = self._offset(start_date, d['o'])

            if d['a'] == 2:
                ev.end_date = ev.start_date + timedelta(days=1)

                ev.start_date = ev.start_date.date()
                ev.end_date = ev.end_date.date()
            elif d['a'] == 1:
                ev.start_date = ev.start_date + timedelta(hours=12)
                ev.end_date = ev.start_date + timedelta(hours=12)
            else:
                assert d['a'] == 0
                ev.end_date = ev.start_date + timedelta(hours=12)

            if user.end and new_date(user.end) < new_date(ev.start_date):
                continue

            yield ev
Example #2
0
    def iter_events(self, start_date, users):
        start_date = start_date.replace(hour=0,
                                        minute=0,
                                        second=0,
                                        microsecond=0)
        for d in self.doc['data']:
            if not d['ls']:  # seems to be validation state
                continue
            assert d['ls'] == 2

            user = users[d['u']]

            ev = BaseCalendarEvent()
            ev.timezone = 'Europe/Paris'
            ev.summary = user.name
            ev.status = STATUS.CONFIRMED
            ev.start_date = self._offset(start_date, d['o'])

            if d['a'] == 2:
                ev.end_date = ev.start_date + timedelta(days=1)

                ev.start_date = ev.start_date.date()
                ev.end_date = ev.end_date.date()
            elif d['a'] == 1:
                ev.start_date = ev.start_date + timedelta(hours=12)
                ev.end_date = ev.start_date + timedelta(hours=12)
            else:
                assert d['a'] == 0
                ev.end_date = ev.start_date + timedelta(hours=12)

            if user.end and new_date(user.end) < new_date(ev.start_date):
                continue

            yield ev
Example #3
0
    def iter_events(self, start_date, users):
        start_date = start_date.replace(hour=0,
                                        minute=0,
                                        second=0,
                                        microsecond=0)

        # key: (userId, date)
        events = {}

        for d in self.doc['data']['items']:
            if not d['leavePeriod']['isConfirmed']:
                # not validated by manager
                continue

            user_id = d['leavePeriod']['ownerId']
            user = users[user_id]

            ev = BaseCalendarEvent()
            ev.timezone = 'Europe/Paris'
            ev.summary = user.name
            ev.status = STATUS.CONFIRMED

            ev.start_date = DateTime().filter(d['date'])
            if not d['isAM']:
                ev.start_date = ev.start_date + timedelta(hours=12)
                ev.end_date = ev.start_date + timedelta(hours=12)
            else:
                ev.end_date = ev.start_date + timedelta(hours=12)

            if user.end and new_date(user.end) < new_date(ev.start_date):
                continue

            event_key = user_id, ev.start_date.date()
            if event_key in events:
                ev.start_date = ev.start_date.date()
                ev.end_date = ev.start_date + timedelta(days=1)

            events[event_key] = ev

        return events.values()
Example #4
0
 def _make_event(self, d):
     event = BaseCalendarEvent(d['id'])
     event.city = u'Paris'
     event.url = d['url']
     event.start_date = d['datetime']
     event.end_date = datetime.combine(d['datetime'].date(), time.max)
     event.summary = d['summary']
     event.category = CATEGORIES.CONCERT
     event.description = d['description']
     event.status = STATUS.CONFIRMED
     event.transp = TRANSP.OPAQUE
     if 'price' in d:
         event.price = d['price']
     if 'address' in d:
         event.location = d['address']
     return event
Example #5
0
 def _make_event(self, d):
     event = BaseCalendarEvent(d['id'])
     event.city = u'Paris'
     event.url = d['url']
     event.start_date = d['datetime']
     event.end_date = datetime.combine(d['datetime'].date(), time.max)
     event.summary = d['summary']
     event.category = CATEGORIES.CONCERT
     event.description = d['description']
     event.status = STATUS.CONFIRMED
     event.transp = TRANSP.OPAQUE
     if 'price' in d:
         event.price = d['price']
     if 'address' in d:
         event.location = d['address']
     return event