예제 #1
0
 def trigger(self):
     if self.fixed_trigger is not None:
         return self.fixed_trigger
     elif self.delta is not None and self.item is not None:
         if Event.installed_on(self.item):
             start = Event(self.item).start
             if start is not None:
                 return start + self.delta
예제 #2
0
 def _after_import_tests(self):
     item = get_item_for_uuid(self.event_uuid)
     work_collection = get_item_for_uuid(self.work_collection_uuid)
     self.assertEqual(len(work_collection.items), 3)
     self._find_sidebar_entry(work_collection)
     self.assertEqual(tuple(item.collections), (work_collection,) )
     self.assertNotEqual(item, None)
     self.assertEqual(item.title, 'Office supplies order')
     self.assert_(Event.installed_on(item))
     self.assertEqual(Event(item).start, self.jan_ninth)
     self.assert_(Event(item).any_time)
     self.failIf(Event(item).all_day)
예제 #3
0
    def _when_source(self):
        """
        Source for displayed date is either fixed_reminder trigger or
        event start.  If neither is available, fall back to created.

        The first-future, or last-past, user-defined date is used.

        """
        past = []
        future = []
        if self._reminder and self._reminder.fixed_trigger:
            fixed_trigger = self._reminder.fixed_trigger
            l = past if is_past(fixed_trigger) else future
            l.append((fixed_trigger, 'reminder'))
        if self.is_event:
            event_start = Event(self._item).start
            if event_start:
                l = past if is_past(event_start) else future
                l.append((event_start, 'event'))
        past.sort()
        future.sort()
        if future:
            return future[0][1]
        elif past:
            return past[-1][1]
        return 'created'
예제 #4
0
 def _when_and_is_day(self):
     if self._when_source == 'event':
         event = Event(self._item)
         return event.start, event.is_day
     elif self._when_source == 'reminder':
         return self._reminder.trigger, False
     else:
         return fromtimestamp(self._item.created), False
예제 #5
0
 def trigger(self):
     if self.fixed_trigger is not None:
         return self.fixed_trigger
     elif self.delta is not None and self.item is not None:
         if Event.installed_on(self.item):
             start = Event(self.item).start
             if start is not None:
                 return start + self.delta
예제 #6
0
def getAliasForItem(item_or_addon):
    item = getattr(item_or_addon, '_item', item_or_addon)
    if getattr(item, 'recurrence_id', None):
        recurrence_id = item.recurrence_id
        master = item.master
        tzinfo = recurrence_id.tzinfo
        # If recurrence_id isn't floating but the master is allDay or anyTime,
        # we have an off-rule modification, its recurrence-id shouldn't be
        # treated as date valued.
        date_value = Event(master).is_day and tzinfo == TimeZone.floating
        if tzinfo != TimeZone.floating:
            recurrence_id = recurrence_id.astimezone(TimeZone.utc)
        recurrence_id = formatDateTime(recurrence_id, date_value, date_value)
        return str_uuid_for(master) + ":" + recurrence_id
    else:
        return str_uuid_for(item)
예제 #7
0
 def test_chex_export(self):
     """Export a simple Event and collection."""
     collection = Collection(title="Fun")
     ChandlerApplication.sidebar_entries.add(SidebarEntry(collection=collection))
     item = Item(title="OK")
     collection.add(item)
     Event(item).add(base_start=self.jan_ninth)
     uuids = [str_uuid_for(x) for x in (collection, item)]
     try:
         handle = file(self.tmp_path, 'wb')
         dump(handle, uuids)
     finally:
         handle.close()
         try:
             os.remove(self.tmp_path)
         except:
             pass
예제 #8
0
 def is_event(self):
     return Event.installed_on(self._item)
예제 #9
0
 def is_event(self):
     return Event.installed_on(self._item)