def startTest(self):

        appView = self.app_ns.itsView

        # make user collection, since only user
        # collections can be displayed as a calendar
        col = QAUITestAppLib.UITestItem("Collection", self.logger)

        #create an event to export
        self.logger.startAction('Create event to export')
        event = QAUITestAppLib.UITestItem("Event", self.logger)
        event_UUID = event.item.itsUUID
        #write some stuff in the event to make it unique
        event.SetAttr(displayName=uw("Original Event"),
                      startDate="01/01/2001",
                      startTime="12:00 AM",
                      body=uw("This is the original event"))
        self.logger.addComment("Created Event to Export")

        #export the event
        path = os.path.join(Globals.chandlerDirectory, "tools/cats/DataFiles")
        filename = 'tempOverwriteTest.ics'
        fullpath = os.path.join(path, filename)
        if os.path.exists(fullpath):
            os.remove(fullpath)
        #Upcast path to unicode since Sharing requires a unicode path
        fullpath = unicode(fullpath, sys.getfilesystemencoding())

        collection = pim.ListCollection(itsView=appView)
        # exporting all Events is VERY expensive, it doesn't seem like a good
        # way to test if events can be exported successfully.  Instead, just
        # export one event.
        #for tmpEvent in Calendar.EventStamp.getCollection(appView):
        #collection.add(tmpEvent)
        collection.add(event.item)
        sharing.exportFile(appView, fullpath, collection)
        application = wx.GetApp()
        application.Yield(True)
        self.logger.addComment("Exported event")

        #change the event after exporting
        event.SetAttr(displayName=uw("Changed Event"),
                      body=uw("This event has been changed"))
        self.logger.addComment("event changed after export")

        #import the original event
        sharing.importFile(appView, fullpath)
        application.Yield(True)
        self.logger.addComment("Imported exported event")

        #check if changed attributes have reverted to original values
        #find imported event by UUID
        self.logger.startAction("Verify event overwritten")
        found = self.app_ns.view.findUUID(event_UUID)
        if found.body == uw('This is the original event') and \
                     found.displayName == uw('Original Event'):
            self.logger.endAction(True, "Event overwriten")
        else:
            self.logger.endAction(False, 'Event not overwriten')
示例#2
0
    def startTest(self):
        
        appView = self.app_ns.itsView

        # make user collection, since only user
        # collections can be displayed as a calendar
        col = QAUITestAppLib.UITestItem("Collection", self.logger)

        #create an event to export
        self.logger.startAction('Create event to export')
        event = QAUITestAppLib.UITestItem("Event", self.logger)
        event_UUID = event.item.itsUUID
        #write some stuff in the event to make it unique
        event.SetAttr(displayName=uw("Original Event"), startDate="01/01/2001", startTime="12:00 AM", body=uw("This is the original event"))
        self.logger.addComment("Created Event to Export")
    
        #export the event
        path = os.path.join(Globals.chandlerDirectory,"tools/cats/DataFiles")
        filename = 'tempOverwriteTest.ics'
        fullpath = os.path.join(path, filename)
        if os.path.exists(fullpath):
            os.remove(fullpath)
        #Upcast path to unicode since Sharing requires a unicode path
        fullpath = unicode(fullpath, sys.getfilesystemencoding())

        collection = pim.ListCollection(itsView=appView)
        # exporting all Events is VERY expensive, it doesn't seem like a good
        # way to test if events can be exported successfully.  Instead, just
        # export one event.
        #for tmpEvent in Calendar.EventStamp.getCollection(appView):
            #collection.add(tmpEvent)
        collection.add(event.item)
        sharing.exportFile(appView, fullpath, collection)
        application = wx.GetApp()
        application.Yield(True)
        self.logger.addComment("Exported event")
        
        #change the event after exporting
        event.SetAttr(displayName=uw("Changed Event"),  body=uw("This event has been changed"))
        self.logger.addComment("event changed after export")
    
        #import the original event
        sharing.importFile(appView, fullpath)
        application.Yield(True)
        self.logger.addComment("Imported exported event")
    
        #check if changed attributes have reverted to original values
            #find imported event by UUID
        self.logger.startAction("Verify event overwritten")
        found = self.app_ns.view.findUUID(event_UUID)
        if found.body == uw('This is the original event') and \
                     found.displayName == uw('Original Event'):
            self.logger.endAction(True, "Event overwriten")
        else:
            self.logger.endAction(False, 'Event not overwriten')
示例#3
0
    def testImport(self):
        path = self.getTestResourcePath('icaluid.ics')
        sharing.importFile(self.view, path)

        # This item had a UUID-friendly icalUID, but its UUID shouldn't be used
        uid1 = 'BED962E5-6042-11D9-BE74-000A95BB2738'
        item1 = sharing.findUID(self.view, uid1)
        self.assert_(item1)
        self.failIfEqual(item1.itsUUID.str16(), uid1)

        # This item did not have a UUID-friendly icalUID, so we hashed it
        uid2 = 'Depeche-Mode'
        item2 = sharing.findUID(self.view, uid1)
        self.assert_(item2)
示例#4
0
    def testImport(self):
        path = self.getTestResourcePath('icaluid.ics')
        sharing.importFile(self.view, path)

        # This item had a UUID-friendly icalUID, but its UUID shouldn't be used
        uid1 = 'BED962E5-6042-11D9-BE74-000A95BB2738'
        item1 = sharing.findUID(self.view, uid1)
        self.assert_(item1)
        self.failIfEqual(item1.itsUUID.str16(), uid1)

        # This item did not have a UUID-friendly icalUID, so we hashed it
        uid2 = 'Depeche-Mode'
        item2 = sharing.findUID(self.view, uid1)
        self.assert_(item2)
示例#5
0
 def startTest(self):
     
     def VerifyEventCreation(title):
         self.logger.startAction("Verify events imported")
         testEvent = self.app_ns.item_named(pim.EventStamp, title)
         if testEvent is not None:
             self.logger.endAction(True, "Testing event creation: '%s'" % title)
         else:
             self.logger.endAction(False, "Testing event creation: '%s' not created" % title)
     
         
     path = os.path.join(Globals.chandlerDirectory, "tools/cats/DataFiles",
         "importTest.ics")
     # Upcast path to unicode since Sharing requires a unicode path
     path = unicode(path, sys.getfilesystemencoding())
     
     self.logger.startAction("Import Large Calendar")
     collection = sharing.importFile(self.app_ns.itsView, path)
     self.app_ns.sidebarCollection.add(collection)
     self.scripting.User.idle()
     self.logger.endAction(True, "Imported calendar")
         
     VerifyEventCreation("Go to the beach")
     VerifyEventCreation("Basketball game")
     VerifyEventCreation("Visit friend")
     VerifyEventCreation("Library")
    def startTest(self):
        def VerifyEventCreation(title):
            self.logger.startAction("Verify events imported")
            testEvent = self.app_ns.item_named(pim.EventStamp, title)
            if testEvent is not None:
                self.logger.endAction(True,
                                      "Testing event creation: '%s'" % title)
            else:
                self.logger.endAction(
                    False, "Testing event creation: '%s' not created" % title)

        path = os.path.join(Globals.chandlerDirectory, "tools/cats/DataFiles",
                            "importTest.ics")
        # Upcast path to unicode since Sharing requires a unicode path
        path = unicode(path, sys.getfilesystemencoding())

        self.logger.startAction("Import Large Calendar")
        collection = sharing.importFile(self.app_ns.itsView, path)
        self.app_ns.sidebarCollection.add(collection)
        self.scripting.User.idle()
        self.logger.endAction(True, "Imported calendar")

        VerifyEventCreation("Go to the beach")
        VerifyEventCreation("Basketball game")
        VerifyEventCreation("Visit friend")
        VerifyEventCreation("Library")
示例#7
0
    def startTest(self):

        QAUITestAppLib.startTestInCalView(self.logger)
        path = os.path.join(Globals.chandlerDirectory, "tools/cats/DataFiles",
                            "TestRecurrence.ics")
        # Upcast path to unicode since Sharing requires a unicode path
        path = unicode(path, sys.getfilesystemencoding())
        self.logger.startAction('Importing TestRecurrence.ics')
        collection = sharing.importFile(self.app_ns.itsView, path)
        self.app_ns.sidebarCollection.add(collection)

        # select the collection
        sidebar = self.app_ns.sidebar
        QAUITestAppLib.scripting.User.emulate_sidebarClick(
            sidebar, collection.displayName)
        scripting.User.idle()

        self.logger.endAction(True, "Importing calendar")

        def VerifyEventCreation(title):
            self.logger.startAction("Verify event titled %s exists" % title)
            testEvent = self.app_ns.item_named(pim.EventStamp, title)
            if testEvent is not None:
                self.logger.endAction(True, " '%s' exists" % title)
            else:
                self.logger.endAction(False, "'%s' not created" % title)

        scripting.User.idle()
        VerifyEventCreation("Yearly Never End")
        VerifyEventCreation("Monthly Meeting")
        VerifyEventCreation("Multi-All Day")
        VerifyEventCreation("All-day never end")

        # bug 5593, set an end date for the "Weekly Never End" event
        sidebar = self.app_ns.sidebar
        scripting.User.emulate_sidebarClick(sidebar, 'TestRecurrence')

        view = QAUITestAppLib.UITestView(self.logger)

        # Need to format date the same way the detail view does
        uiView = wx.GetApp().UIRepositoryView
        goto = datetime.date(2006, 5, 1)
        value = datetime.datetime.combine(
            goto, datetime.time(0, tzinfo=uiView.tzinfo.default))
        dateStr = pim.shortDateFormat.format(uiView, value)

        view.GoToDate(dateStr)

        event = QAUITestAppLib.GetOccurrence('Weekly Never End', goto)
        QAUITestAppLib.UITestItem(event,
                                  self.logger).SetAttr(recurrenceEnd=dateStr)

        # event has been deleted by changing recurrence, get a new one
        event = QAUITestAppLib.GetOccurrence('Weekly Never End', goto)
        testItem = QAUITestAppLib.UITestItem(event, self.logger)
        testItem.SelectItem(catchException=True)

        # Make sure this occurrence exists and was able to be selected
        testItem.Check_ItemSelected()
示例#8
0
    def startTest(self):

        QAUITestAppLib.startTestInCalView(self.logger)
        path = os.path.join(Globals.chandlerDirectory, "tools/cats/DataFiles", "TestRecurrence.ics")
        # Upcast path to unicode since Sharing requires a unicode path
        path = unicode(path, sys.getfilesystemencoding())
        self.logger.startAction("Importing TestRecurrence.ics")
        collection = sharing.importFile(self.app_ns.itsView, path)
        self.app_ns.sidebarCollection.add(collection)

        # select the collection
        sidebar = self.app_ns.sidebar
        QAUITestAppLib.scripting.User.emulate_sidebarClick(sidebar, collection.displayName)
        scripting.User.idle()

        self.logger.endAction(True, "Importing calendar")

        def VerifyEventCreation(title):
            self.logger.startAction("Verify event titled %s exists" % title)
            testEvent = self.app_ns.item_named(pim.EventStamp, title)
            if testEvent is not None:
                self.logger.endAction(True, " '%s' exists" % title)
            else:
                self.logger.endAction(False, "'%s' not created" % title)

        scripting.User.idle()
        VerifyEventCreation("Yearly Never End")
        VerifyEventCreation("Monthly Meeting")
        VerifyEventCreation("Multi-All Day")
        VerifyEventCreation("All-day never end")

        # bug 5593, set an end date for the "Weekly Never End" event
        sidebar = self.app_ns.sidebar
        scripting.User.emulate_sidebarClick(sidebar, "TestRecurrence")

        view = QAUITestAppLib.UITestView(self.logger)

        # Need to format date the same way the detail view does
        uiView = wx.GetApp().UIRepositoryView
        goto = datetime.date(2006, 5, 1)
        value = datetime.datetime.combine(goto, datetime.time(0, tzinfo=uiView.tzinfo.default))
        dateStr = pim.shortDateFormat.format(uiView, value)

        view.GoToDate(dateStr)

        event = QAUITestAppLib.GetOccurrence("Weekly Never End", goto)
        QAUITestAppLib.UITestItem(event, self.logger).SetAttr(recurrenceEnd=dateStr)

        # event has been deleted by changing recurrence, get a new one
        event = QAUITestAppLib.GetOccurrence("Weekly Never End", goto)
        testItem = QAUITestAppLib.UITestItem(event, self.logger)
        testItem.SelectItem(catchException=True)

        # Make sure this occurrence exists and was able to be selected
        testItem.Check_ItemSelected()
    def startTest(self):

        appView = self.app_ns.itsView
        today = strftime('%m/%d/%Y', localtime())

        colName = "deleteThenImport"
        eventName = "eventToTest"

        #create a collection
        collection = QAUITestAppLib.UITestItem("Collection", self.logger)
        collection.SetDisplayName(colName)
        sb = self.app_ns.sidebar
        scripting.User.emulate_sidebarClick(sb, colName)

        #create an event
        ev = QAUITestAppLib.UITestItem('Event', self.logger)
        ev.SetAttr(displayName=eventName,
                   startDate=today,
                   startTime="12:00 PM")

        #create a path to export to
        reportDir = Globals.options.profileDir
        fullpath = os.path.join(reportDir, 'deleteThenImport.ics')
        if os.path.exists(fullpath):
            os.remove(fullpath)
        fullpath = unicode(fullpath, sys.getfilesystemencoding())

        #export
        sharing.exportFile(appView, fullpath, collection.item)

        #delete collection
        scripting.User.emulate_sidebarClick(sb, colName)
        collection.DeleteCollection()

        #import event back in
        collection = sharing.importFile(appView, fullpath)
        self.app_ns.sidebarCollection.add(collection)
        scripting.User.idle()

        #verify
        ev.Check_ItemInCollection("Trash", expectedResult=False)
        ev.Check_ItemInCollection(colName, expectedResult=True)
    def startTest(self):
    
        appView = self.app_ns.itsView
        today = strftime('%m/%d/%Y',localtime())
        
        colName = "deleteThenImport"
        eventName = "eventToTest"

        #create a collection
        collection = QAUITestAppLib.UITestItem("Collection", self.logger)
        collection.SetDisplayName(colName)
        sb=self.app_ns.sidebar
        scripting.User.emulate_sidebarClick(sb,colName) 
        
        #create an event
        ev=QAUITestAppLib.UITestItem('Event', self.logger)
        ev.SetAttr(displayName=eventName, startDate=today, startTime="12:00 PM")
        
        #create a path to export to
        reportDir = Globals.options.profileDir
        fullpath = os.path.join(reportDir,'deleteThenImport.ics')
        if os.path.exists(fullpath):
            os.remove(fullpath)
        fullpath = unicode(fullpath, sys.getfilesystemencoding())
        
        #export
        sharing.exportFile(appView, fullpath, collection.item)
        
        #delete collection
        scripting.User.emulate_sidebarClick(sb,colName) 
        collection.DeleteCollection()
        
        #import event back in
        collection = sharing.importFile(appView, fullpath)
        self.app_ns.sidebarCollection.add(collection)
        scripting.User.idle()    
            
        #verify
        ev.Check_ItemInCollection("Trash", expectedResult=False)
        ev.Check_ItemInCollection(colName, expectedResult=True)
 def Import(self, view, filename):
     path = self.getTestResourcePath(filename)
     self.importedCollection = sharing.importFile(view, path)
示例#12
0
 def testImport(self):
     if os.environ.get('CHANDLER_PERFORMANCE_TEST'):
         path = self.getTestResourcePath('3kevents.ics')
         sharing.importFile(self.view, path)
示例#13
0
 def Import(self, view, filename):
     path = self.getTestResourcePath(filename)
     self.importedCollection = sharing.importFile(view, path)
示例#14
0
def installParcel(parcel, oldVersion=None):

    pim_ns = schema.ns('osaf.pim', parcel)
    sharing_ns = schema.ns('osaf.sharing', parcel)

    ClientIdentifier.update(parcel, 'clientID')

    ApplicationPrefs.update(parcel, 'prefs')

    AutoRestorePrefs.update(parcel, "autoRestorePrefs")

    message = _(u'User')

    me = pim.Contact.update(
        parcel,
        'me',
        # L10N: The word 'Me' is used to represent the
        #       current Chandler user.
        displayName=_(u'Me'),
        contactName=pim.ContactName.update(
            parcel,
            'meName',
            firstName=u'Chandler',
            #XXX Since the notion of 'me' may be going away
            #    there is no current need to refactor the
            #    last name attribute to the LocalizableString type.
            #    Thus for now will convert the c{Message} object
            #    returned from the c{ChandlerMessageFactory}
            #    to Unicode. This decision will be revisited later.
            lastName=unicode(message),
        ),
        references=[pim_ns.currentContact])

    # The Sidebar collection
    sidebarListCollection = pim.ListCollection.update(
        parcel,
        'sidebarCollection',
        inclusions=[
            pim_ns.allCollection, pim_ns.inCollection, pim_ns.outCollection,
            pim_ns.trashCollection
        ])

    testReply = pim.mail.EmailAddress.update(parcel, 'TestReplyAddress')

    # [i18n] Test Accounts are not displayed to the user and
    # do not require localization
    testSmtp = pim.mail.SMTPAccount.update(parcel,
                                           'TestSMTPAccount',
                                           displayName=u'Test SMTP Account',
                                           password=password.Password.update(
                                               parcel,
                                               'TestSMTPAccountPassword'),
                                           isActive=False)

    pim.mail.IMAPAccount.update(parcel,
                                'TestIMAPAccount',
                                displayName=u'Test IMAP mail',
                                replyToAddress=testReply,
                                password=password.Password.update(
                                    parcel, 'TestIMAPAccountPassword'),
                                isActive=False)

    pim.mail.POPAccount.update(parcel,
                               'TestPOPAccount',
                               displayName=u'Test POP mail',
                               replyToAddress=testReply,
                               defaultSMTPAccount=testSmtp,
                               password=password.Password.update(
                                   parcel, 'TestPOPAccountPassword'),
                               isActive=False)

    osafDev = pim.Contact.update(parcel,
                                 'OSAFContact',
                                 emailAddress=u'*****@*****.**',
                                 contactName=pim.ContactName.update(
                                     parcel,
                                     'OSAFContactName',
                                     firstName=u'OSAF',
                                     lastName=u'Development'))

    # OOTB collections and items (bugs 6545, 11772)
    # http://chandlerproject.org/bin/view/Journal/PreviewOOTBChandlerExperience
    #
    # (1) Don't create these in //parcels, or they won't get dumped
    # (2) Don't create these if reloading, or else there will be endless
    #     duplication of items/events
    # (3) We do want new UUIDs, so different users can share these
    #     collections/items to the same morsecode server
    # (4) The Welcome Event should be created regardless of whether
    #     we're reloading, because summaryblocks references it.
    #     (Maybe there's a better way to have it selected in the
    #      detail view?) -- Grant
    # (5) We create

    triageWhenValues = [datetime.datetime.now(parcel.itsView.tzinfo.default)]

    def changeTriage(itemOrStamp, triageValue):
        triageWhen = triageWhenValues.pop()
        item = getattr(itemOrStamp, 'itsItem', itemOrStamp)
        item.setTriageStatus(triageValue, triageWhen)
        triageWhenValues.append(triageWhen - datetime.timedelta(seconds=5))

    # OOTB item: Welcome Event
    noonToday = datetime.datetime.combine(
        datetime.date.today(),
        datetime.time(12, tzinfo=parcel.itsView.tzinfo.floating))

    WelcomeEvent = pim.EventStamp.update(
        parcel,
        'WelcomeEvent',
        # L10N: The Trademark symbol "TM" is represented in Unicode as U+2122
        displayName=_(u'Welcome to Chandler\u2122'),
        startTime=noonToday,
        duration=datetime.timedelta(minutes=60),
        anyTime=False,
        read=False,
        creator=osafDev,
        location=pim.Location.update(
            parcel,
            "OSAFLocation",
            displayName="Open Source Applications Foundation",
        ),
    )

    # L10N: The Trademark symbol "TM" is represented in Unicode as U+2122
    body = _(
        u"""Welcome to Chandler\u2122 %(version)s. Here is a list of resources to help you get started:

1. Get a tour of Chandler
(http://chandlerproject.org/tour).

2. Learn how to import calendars and set up Chandler to back up and share
(http://chandlerproject.org/getstarted).

3. Back up your data and Share by signing up for a Chandler Hub account
(http://hub.chandlerproject.org/signup).

4. Ask for help by sending mail to mailto:[email protected].

5. Learn more about the project on our wiki
(http://chandlerproject.org/wikihome).

6. Get involved and contribute to the project
(http://chandlerproject.org/getinvolved).

Thank you for trying Chandler!

The Chandler Team""") % {
            'version': version.version
        }

    WelcomeEvent.body = body
    WelcomeEvent.changeEditState(pim.Modification.created)
    changeTriage(WelcomeEvent, pim.TriageEnum.now)
    pim.TaskStamp(WelcomeEvent).add()

    if Globals.options.reload:
        schema.ns('osaf.pim', parcel.itsView).allCollection.add(WelcomeEvent)
    else:
        # OOTB user defined collections: collections should be in mine
        mine = schema.ns("osaf.pim", parcel.itsView).mine

        def makeCollection(name, checked, color):
            collection = pim.SmartCollection(itsView=parcel.itsView,
                                             displayName=name)
            # include collection in overlays, as spec'ed
            UserCollection(collection).checked = checked
            # set the collection color as spec'ed
            UserCollection(collection).setColor(color)

            sidebarListCollection.add(collection)
            mine.addSource(collection)

            return collection

        # OOTB user defined collections: Work, Home and Fun
        work = makeCollection(_(u"Work"), True, u'Blue')
        home = makeCollection(_(u"Home"), True, u'Red')
        fun = makeCollection(_(u"Fun"), False, u'Plum')

        # OOTB shared collection: U.S. Holidays
        holidays = makeCollection(_(u"U.S. Holidays"), True, u'Green')

        holidaysPath = pkg_resources.resource_filename(__name__,
                                                       "us_holidays.ics")
        sharing.importFile(parcel.itsView, holidaysPath, collection=holidays)

        dashboard = schema.ns("osaf.pim", parcel.itsView).allCollection

        # Add Welcome item to OOTB collections
        home.add(WelcomeEvent)
        work.add(WelcomeEvent)

        thisWeek = CalendarUtility.getCalendarRange(noonToday.date())

        def getDayInThisWeek(weekday):

            res = thisWeek[0]
            while res.weekday() != weekday:
                res += datetime.timedelta(days=1)
            return res

        # OOTB item 1: Next dentist appointment?
        event1 = pim.CalendarEvent(
            itsView=parcel.itsView,
            displayName=_(u"Next dentist appointment?"),
            startTime=noonToday.replace(hour=9),
            anyTime=True,
            collections=[home],
            read=True,
        )
        event1.itsItem.changeEditState(pim.Modification.created,
                                       when=noonToday.replace(hour=8))
        changeTriage(event1, pim.TriageEnum.now)

        # OOTB item #2: Tell a friend about Chandler
        item2 = pim.Note(
            itsView=parcel.itsView,
            displayName=_(u"Tell a friend about Chandler"),
            read=True,
            body=_(
                u"""Try sharing a collection with family, friends or colleagues.

Sign up for a Chandler Hub account to get started: http://hub.chandlerproject.org
"""),
        )

        schema.ns("osaf.pim", parcel.itsView).allCollection.add(item2)
        item2.changeEditState(pim.Modification.created,
                              when=noonToday.replace(hour=8))
        changeTriage(item2, pim.TriageEnum.now)

        # OOTB item #3: Write-up
        task3 = pim.Task(
            itsView=parcel.itsView,
            displayName=_(u"Write-up..."),
            collections=[work],
            read=True,
            body=
            _(u"""Start jotting down ideas for that big write-up you should really have started last week!

.
.
.
"""),
        )
        task3.itsItem.changeEditState(pim.Modification.created)
        changeTriage(task3, pim.TriageEnum.now)

        # OOTB item #4: Follow up
        task4 = pim.Task(
            itsView=parcel.itsView,
            displayName=_(u"Follow up with...on..."),
            read=True,
            body=
            _(u"""Maintain a list of things you need to discuss with a colleague:
.
.
.

(Click on the clock icon to add this note to the calendar for the next time you're going to meet with them.)
"""),
        )
        dashboard.add(task4.itsItem)
        task4.itsItem.changeEditState(pim.Modification.created)
        changeTriage(task4, pim.TriageEnum.now)

        # OOTB item #5: Start planning vacation
        task5 = pim.Task(
            itsView=parcel.itsView,
            displayName=_(u"Start planning vacation"),
            read=True,
            collections=[home],
            body=_("""Places you could go?
.
.
.

Activities you'd like to try?
.
.
.

Interesting travel articles?
.
.
.
"""),
        )

        changeTriage(task5, pim.TriageEnum.now)
        task5.itsItem.changeEditState(pim.Modification.created)

        # OOTB item #6: Bi-Weekly Status Report
        event5 = pim.CalendarEvent(
            itsView=parcel.itsView,
            displayName=_(u"Bi-Weekly Status Report"),
            startTime=noonToday,
            anyTime=True,
            read=True,
            collections=[work],
            body=_("""What have you been up to the last couple of weeks?
.
.
.
"""),
        )

        def makeRecurring(event, **kw):
            rule = pim.calendar.Recurrence.RecurrenceRule(
                itsView=parcel.itsView, **kw)

            event.rruleset = pim.calendar.Recurrence.RecurrenceRuleSet(
                itsView=parcel.itsView, rrules=[rule])
            for item in event.modifications:
                changeTriage(item, item._triageStatus)

        pim.TaskStamp(event5).add()
        event5.itsItem.changeEditState(pim.Modification.created)

        makeRecurring(event5, freq='weekly', interval=2)

        # OOTB item #6: Office supplies order
        startTime6 = datetime.datetime.combine(getDayInThisWeek(4),
                                               noonToday.timetz())

        event6 = pim.CalendarEvent(
            itsView=parcel.itsView,
            displayName=_(u"Office supplies order"),
            startTime=startTime6,
            anyTime=True,
            read=True,
            collections=[work],
            body=_(u"""Maintain a list of supplies you need to get every month:
.
.
.

(Share it with others so you can all maintain the list together!)
"""))
        changeTriage(event6, pim.TriageEnum.done)
        event6.itsItem.changeEditState(pim.Modification.created)
        makeRecurring(event6, freq='monthly')

        # OOTB item #7: Salsa class
        startTime7 = noonToday.replace(hour=14, minute=30)
        delta = 14 + startTime7.date().weekday() - 6
        startTime7 -= datetime.timedelta(days=delta)
        until7 = startTime7 + datetime.timedelta(days=28)
        event7 = pim.CalendarEvent(itsView=parcel.itsView,
                                   displayName=_(u"Salsa Class"),
                                   startTime=startTime7,
                                   duration=datetime.timedelta(hours=1),
                                   anyTime=False,
                                   read=True,
                                   collections=[home, fun],
                                   body=_(u"""Assignment for this week:
.
.
.

Remember to bring:
.
.
.
"""))
        event7.itsItem.changeEditState(pim.Modification.created,
                                       when=startTime7)
        changeTriage(event7, pim.TriageEnum.done)
        makeRecurring(event7, freq='weekly', until=until7)

        # A hack to get this occurrence to appear in the dashboard
        event7.getFirstOccurrence().getNextOccurrence().changeThis()
        for m in sorted(event7.modifications,
                        key=lambda o: pim.EventStamp(o).startTime):
            changeTriage(m, m._triageStatus)

        # OOTB item #8: Brunch potluck...
        startTime8 = datetime.datetime.combine(
            getDayInThisWeek(6), datetime.time(11, 0, tzinfo=noonToday.tzinfo))

        event8 = pim.CalendarEvent(
            itsView=parcel.itsView,
            displayName=_(u"Brunch potluck..."),
            startTime=startTime8,
            duration=datetime.timedelta(hours=2),
            anyTime=False,
            read=True,
            collections=[home, fun],
            body=_(u"""Directions
.
.
.

Ideas for games to bring...
.
.
.

Sign up to bring food...
.
.
.
"""),
        )
        changeTriage(event8, event8.autoTriage())
        event8.itsItem.changeEditState(pim.Modification.created)

        # OOTB Item #9: Ideas for presents
        item9 = pim.Note(
            itsView=parcel.itsView,
            displayName=_(u"Ideas for presents"),
            read=True,
            collections=[home],
            body=
            _(u"""Maintain a list of possible presents for family, friends and colleagues so you're never short on ideas!
.
.
.
"""),
        )
        changeTriage(item9, pim.TriageEnum.later)
        item9.changeEditState(pim.Modification.edited)

        # OOTB Item #10: Thank you notes
        item10 = pim.Note(
            itsView=parcel.itsView,
            displayName=_(u"Thank you notes"),
            read=True,
            collections=[home],
            body=
            _(u"""Who do you need to write thank you notes to? and for what reason?
.
.
.


"""),
        )

        changeTriage(item10, pim.TriageEnum.later)
        item10.changeEditState(pim.Modification.created)

        # OOTB Item #11: Movie list
        item11 = pim.Note(
            itsView=parcel.itsView,
            displayName=_(u"Movie list"),
            read=True,
            collections=[fun, home],
            body=_(u"""Movies you want to see:

.
.
.
"""),
        )

        changeTriage(item11, pim.TriageEnum.later)
        item11.changeEditState(pim.Modification.created)

        # OOTB Item #12: Book list
        item12 = pim.Note(
            itsView=parcel.itsView,
            displayName=_(u"Book list"),
            read=True,
            collections=[fun, home],
            body=_(
                u"""Book recommendations you've been meaning to follow up on:

.
.
.
"""),
        )

        changeTriage(item12, pim.TriageEnum.later)
        item12.changeEditState(pim.Modification.created)

        # OOTB Item #13: File taxes
        startTime13 = noonToday.replace(month=4, day=15)
        alarmTime13 = startTime13.replace(day=1)
        if alarmTime13 < noonToday:
            alarmTime13 = alarmTime13.replace(year=alarmTime13.year + 1)
            startTime13 = startTime13.replace(year=startTime13.year + 1)

        event13 = pim.CalendarEvent(
            itsView=parcel.itsView,
            startTime=startTime13,
            displayName=_(u"File taxes!"),
            read=True,
            collections=[home],
            body=_(u"""What forms do you have in hand?
.
.
.

What are you missing?
.
.
.

Questions for your accountant?
.
.
.
"""),
        )

        pim.TaskStamp(event13).add()
        event13.itsItem.changeEditState(pim.Modification.created)
        changeTriage(event13, pim.TriageEnum.later)
        event13.itsItem.userReminderTime = alarmTime13

        # OOTB Item #14: Class Trip: Exhibit on Sound!
        location14 = pim.Location.update(
            parcel,
            "Exploratorium",
            displayName="Exploratorium",
        )

        startTime14 = datetime.datetime.combine(
            getDayInThisWeek(6), datetime.time(15, tzinfo=noonToday.tzinfo))

        event14 = pim.CalendarEvent(
            itsView=parcel.itsView,
            startTime=startTime14,
            displayName=_(u"Class Trip: Exhibit on Sound!"),
            read=True,
            location=location14,
            collections=[fun],
            body=_(u"""Directions...
.
.
.
"""),
        )
        event14.itsItem.changeEditState(pim.Modification.edited,
                                        when=startTime14)
        changeTriage(event14, pim.TriageEnum.done)

        # OOTB Item #15: Download Chandler!
        note15 = pim.Note(
            itsView=parcel.itsView,
            displayName=_(u"Download Chandler!"),
            read=True,
        )
        dashboard.add(note15)
        done15 = datetime.datetime.now(parcel.itsView.tzinfo.default)
        done15 -= datetime.timedelta(minutes=5)
        done15 = done15.replace(second=0, microsecond=0)
        changeTriage(note15, pim.TriageEnum.done)
        note15.changeEditState(pim.Modification.edited, when=done15)

        # Set up sharing for holidays
        share = sharing.Share(itsView=parcel.itsView,
                              mode='get',
                              contents=holidays,
                              established=True)
        filters = set([
            'cid:[email protected]', 'cid:[email protected]',
            'cid:[email protected]', 'cid:[email protected]',
            'cid:[email protected]'
        ])
        share.conduit = sharing.WebDAVMonolithicRecordSetConduit(
            itsParent=share,
            host=u'hub.chandlerproject.org',
            port=443,
            sharePath=u'webcal/collection',
            shareName=u'7febe2f4-324c-11dd-d9e4-0016cbca6aed?ticket=01q75n1sy0',
            useSSL=True,
            filters=filters,
            translator=sharing.SharingTranslator,
            serializer=sharing.ICSSerializer)
        share.conduit.ticketReadOnly = share.conduit.ticket
        sharing.SharedItem(share.contents).add()
        sharing.SharedItem(share.contents).shares.append(share)

    # Set up the main web server
    from osaf import webserver

    startup.Startup.update(parcel,
                           "startServers",
                           invoke="osaf.webserver.start_servers")

    webserver.Server.update(
        parcel,
        "mainServer",
        # Port to listen on.  1888 was the year Raymond Chandler was born.
        port=1888,

        # This path specifies the "doc root" of this web server, and is
        # relative to webserver/servers, but you may also put in an
        # absolute path if you wish.
        #
        path=unicode(os.path.join("parcels", "osaf", "app", "webhome")),
        resources=[
            webserver.Resource.update(
                parcel,
                "lobsResource",
                displayName=u"Lob Server",
                location=u"lobs",
                resourceClass=schema.importString(
                    "osaf.servlets.lobviewer.LobViewerResource"),
            ),
            webserver.Resource.update(
                parcel,
                "photoResource",
                displayName=u"Photo Viewer",
                location=u"photos",
                resourceClass=schema.importString(
                    "osaf.servlets.photo.PhotosResource"),
            ),
            webserver.Resource.update(parcel,
                                      "repoResource",
                                      displayName=u"Repository Viewer",
                                      location=u"repo",
                                      resourceClass=schema.importString(
                                          "osaf.servlets.repo.RepoResource"),
                                      autoView=False),
            webserver.Resource.update(parcel,
                                      "prefResource",
                                      displayName=u'Preference Editor',
                                      location=u"prefs",
                                      resourceClass=schema.importString(
                                          "osaf.servlets.prefs.PrefResource"),
                                      autoView=False),
            webserver.Resource.update(
                parcel,
                "xmlrpcResource",
                displayName=u'XML-RPC Service',
                location=u"xmlrpc",
                resourceClass=schema.importString(
                    "osaf.servlets.xmlrpc.XmlRpcResource"),
                autoView=False),
        ])

    from osaf.app import updates

    # Subtract 15 minutes from lastRun so that in a week's
    # time we don't conflict with the "compact" trask.
    updates.UpdateCheckTask.update(parcel,
                                   'updateCheckTask',
                                   interval=datetime.timedelta(days=1),
                                   lastRun=datetime.datetime.now() -
                                   datetime.timedelta(minutes=15))

    # Compact task should come last
    from osaf.app import compact
    compact.CompactTask.update(parcel, 'compactTask')
 def testImport(self):
     if os.environ.get('CHANDLER_PERFORMANCE_TEST'):
         path = self.getTestResourcePath('3kevents.ics')
         sharing.importFile(self.view, path)
示例#16
0
def installParcel(parcel, oldVersion=None):

    pim_ns = schema.ns('osaf.pim', parcel)
    sharing_ns = schema.ns('osaf.sharing', parcel)
    
    ClientIdentifier.update(parcel, 'clientID')

    ApplicationPrefs.update(parcel, 'prefs')

    AutoRestorePrefs.update(parcel, "autoRestorePrefs")

    message = _(u'User')

    me = pim.Contact.update(parcel, 'me',
        # L10N: The word 'Me' is used to represent the
        #       current Chandler user.
        displayName=_(u'Me'),
        contactName=pim.ContactName.update(parcel, 'meName',
           firstName=u'Chandler',
           #XXX Since the notion of 'me' may be going away
           #    there is no current need to refactor the
           #    last name attribute to the LocalizableString type.
           #    Thus for now will convert the c{Message} object
           #    returned from the c{ChandlerMessageFactory}
           #    to Unicode. This decision will be revisited later.
           lastName=unicode(message),
        ),
        references=[pim_ns.currentContact]
    )

    # The Sidebar collection
    sidebarListCollection = pim.ListCollection.update(parcel,
        'sidebarCollection',
        inclusions=[pim_ns.allCollection,
                    pim_ns.inCollection,
                    pim_ns.outCollection,
                    pim_ns.trashCollection]
    )

    testReply = pim.mail.EmailAddress.update(parcel, 'TestReplyAddress')

    # [i18n] Test Accounts are not displayed to the user and 
    # do not require localization
    testSmtp = pim.mail.SMTPAccount.update(parcel, 'TestSMTPAccount',
        displayName=u'Test SMTP Account',
        password=password.Password.update(parcel, 'TestSMTPAccountPassword'),
        isActive=False
    )

    pim.mail.IMAPAccount.update(parcel, 'TestIMAPAccount',
        displayName=u'Test IMAP mail',
        replyToAddress=testReply,
        password=password.Password.update(parcel, 'TestIMAPAccountPassword'),
        isActive=False
    )

    pim.mail.POPAccount.update(parcel, 'TestPOPAccount',
        displayName=u'Test POP mail',
        replyToAddress=testReply,
        defaultSMTPAccount=testSmtp,
        password=password.Password.update(parcel, 'TestPOPAccountPassword'),
        isActive=False
    )

    osafDev = pim.Contact.update(parcel, 'OSAFContact',
        emailAddress=u'*****@*****.**',
        contactName=pim.ContactName.update(parcel, 'OSAFContactName',
           firstName=u'OSAF',
           lastName=u'Development'
        )
    )
    
    # OOTB collections and items (bugs 6545, 11772)
    # http://chandlerproject.org/bin/view/Journal/PreviewOOTBChandlerExperience
    #
    # (1) Don't create these in //parcels, or they won't get dumped
    # (2) Don't create these if reloading, or else there will be endless
    #     duplication of items/events
    # (3) We do want new UUIDs, so different users can share these
    #     collections/items to the same morsecode server
    # (4) The Welcome Event should be created regardless of whether
    #     we're reloading, because summaryblocks references it.
    #     (Maybe there's a better way to have it selected in the
    #      detail view?) -- Grant
    # (5) We create
    
    triageWhenValues = [datetime.datetime.now(parcel.itsView.tzinfo.default)]
    def changeTriage(itemOrStamp, triageValue):
        triageWhen = triageWhenValues.pop()
        item = getattr(itemOrStamp, 'itsItem', itemOrStamp)
        item.setTriageStatus(triageValue, triageWhen)
        triageWhenValues.append(triageWhen - datetime.timedelta(seconds=5))


    # OOTB item: Welcome Event
    noonToday = datetime.datetime.combine(
        datetime.date.today(),
        datetime.time(12, tzinfo=parcel.itsView.tzinfo.floating))

    WelcomeEvent = pim.EventStamp.update(parcel, 'WelcomeEvent',
        # L10N: The Trademark symbol "TM" is represented in Unicode as U+2122
        displayName=_(u'Welcome to Chandler\u2122'),
        startTime=noonToday,
        duration=datetime.timedelta(minutes=60),
        anyTime=False,
        read=False,
        creator=osafDev,
        location=pim.Location.update(parcel, "OSAFLocation",
            displayName="Open Source Applications Foundation",
        ),
    )

    # L10N: The Trademark symbol "TM" is represented in Unicode as U+2122
    body = _(u"""Welcome to Chandler\u2122 %(version)s. Here is a list of resources to help you get started:

1. Get a tour of Chandler
(http://chandlerproject.org/tour).

2. Learn how to import calendars and set up Chandler to back up and share
(http://chandlerproject.org/getstarted).

3. Back up your data and Share by signing up for a Chandler Hub account
(http://hub.chandlerproject.org/signup).

4. Ask for help by sending mail to mailto:[email protected].

5. Learn more about the project on our wiki
(http://chandlerproject.org/wikihome).

6. Get involved and contribute to the project
(http://chandlerproject.org/getinvolved).

Thank you for trying Chandler!

The Chandler Team""") % { 'version' : version.version }

    WelcomeEvent.body = body
    WelcomeEvent.changeEditState(pim.Modification.created)
    changeTriage(WelcomeEvent, pim.TriageEnum.now)
    pim.TaskStamp(WelcomeEvent).add()
    
    
    if Globals.options.reload:
        schema.ns('osaf.pim', parcel.itsView).allCollection.add(WelcomeEvent)
    else:
        # OOTB user defined collections: collections should be in mine
        mine = schema.ns("osaf.pim", parcel.itsView).mine
        def makeCollection(name, checked, color):
            collection = pim.SmartCollection(
                            itsView=parcel.itsView,
                            displayName=name
                        )
            # include collection in overlays, as spec'ed
            UserCollection(collection).checked = checked
            # set the collection color as spec'ed
            UserCollection(collection).setColor(color)

            sidebarListCollection.add(collection)
            mine.addSource(collection)
            
            return collection
            
        # OOTB user defined collections: Work, Home and Fun
        work = makeCollection(_(u"Work"), True, u'Blue')
        home = makeCollection(_(u"Home"), True, u'Red')
        fun = makeCollection(_(u"Fun"), False, u'Plum')
        
        # OOTB shared collection: U.S. Holidays
        holidays = makeCollection(_(u"U.S. Holidays"), True, u'Green')

        holidaysPath = pkg_resources.resource_filename(__name__,
                                                       "us_holidays.ics")
        sharing.importFile(parcel.itsView, holidaysPath, collection=holidays)


        dashboard = schema.ns("osaf.pim", parcel.itsView).allCollection

        # Add Welcome item to OOTB collections
        home.add(WelcomeEvent)
        work.add(WelcomeEvent)
        
        
        thisWeek = CalendarUtility.getCalendarRange(noonToday.date())

        def getDayInThisWeek(weekday):
        
            res = thisWeek[0]
            while res.weekday() != weekday:
                res += datetime.timedelta(days=1)
            return res

        # OOTB item 1: Next dentist appointment?
        event1 = pim.CalendarEvent(
                    itsView=parcel.itsView,
                    displayName=_(u"Next dentist appointment?"),
                    startTime=noonToday.replace(hour=9),
                    anyTime=True,
                    collections=[home],
                    read=True,
                 )
        event1.itsItem.changeEditState(pim.Modification.created,
                                       when=noonToday.replace(hour=8))
        changeTriage(event1, pim.TriageEnum.now)

        # OOTB item #2: Tell a friend about Chandler
        item2 = pim.Note(
                    itsView=parcel.itsView,
                    displayName=_(u"Tell a friend about Chandler"),
                    read=True,
                    body=_(
u"""Try sharing a collection with family, friends or colleagues.

Sign up for a Chandler Hub account to get started: http://hub.chandlerproject.org
"""),
               )

        schema.ns("osaf.pim", parcel.itsView).allCollection.add(item2)
        item2.changeEditState(pim.Modification.created,
                                       when=noonToday.replace(hour=8))
        changeTriage(item2, pim.TriageEnum.now)
        
        # OOTB item #3: Write-up
        task3 = pim.Task(
                    itsView=parcel.itsView,
                    displayName=_(u"Write-up..."),
                    collections=[work],
                    read=True,
                    body=_(
u"""Start jotting down ideas for that big write-up you should really have started last week!

.
.
.
"""),
               )
        task3.itsItem.changeEditState(pim.Modification.created)
        changeTriage(task3, pim.TriageEnum.now)

        # OOTB item #4: Follow up
        task4 = pim.Task(
                    itsView=parcel.itsView,
                    displayName=_(u"Follow up with...on..."),
                    read=True,
                    body=_(
u"""Maintain a list of things you need to discuss with a colleague:
.
.
.

(Click on the clock icon to add this note to the calendar for the next time you're going to meet with them.)
"""),
               )
        dashboard.add(task4.itsItem)
        task4.itsItem.changeEditState(pim.Modification.created)
        changeTriage(task4, pim.TriageEnum.now)

        # OOTB item #5: Start planning vacation
        task5 = pim.Task(
                    itsView=parcel.itsView,
                    displayName=_(u"Start planning vacation"),
                    read=True,
                    collections=[home],
                    body=_(
"""Places you could go?
.
.
.

Activities you'd like to try?
.
.
.

Interesting travel articles?
.
.
.
"""),
               )

        changeTriage(task5, pim.TriageEnum.now)
        task5.itsItem.changeEditState(pim.Modification.created)

        # OOTB item #6: Bi-Weekly Status Report
        event5 = pim.CalendarEvent(
                     itsView=parcel.itsView,
                     displayName=_(u"Bi-Weekly Status Report"),
                     startTime=noonToday,
                     anyTime=True,
                     read=True,
                     collections=[work],
                     body=_(
"""What have you been up to the last couple of weeks?
.
.
.
"""),
                 )
        def makeRecurring(event, **kw):
             rule = pim.calendar.Recurrence.RecurrenceRule(
                        itsView=parcel.itsView,
                        **kw
                    )

             event.rruleset = pim.calendar.Recurrence.RecurrenceRuleSet(
                        itsView=parcel.itsView,
                        rrules=[rule]
                    )
             for item in event.modifications:
                 changeTriage(item, item._triageStatus)

        pim.TaskStamp(event5).add()
        event5.itsItem.changeEditState(pim.Modification.created)

        makeRecurring(event5, freq='weekly', interval=2)

        # OOTB item #6: Office supplies order
        startTime6 = datetime.datetime.combine(getDayInThisWeek(4),
                                               noonToday.timetz())

        event6 = pim.CalendarEvent(
                     itsView=parcel.itsView,
                     displayName=_(u"Office supplies order"),
                     startTime=startTime6,
                     anyTime=True,
                     read=True,
                     collections=[work],
                     body=_(
u"""Maintain a list of supplies you need to get every month:
.
.
.

(Share it with others so you can all maintain the list together!)
""")
                )
        changeTriage(event6, pim.TriageEnum.done)
        event6.itsItem.changeEditState(pim.Modification.created)
        makeRecurring(event6, freq='monthly')

        # OOTB item #7: Salsa class
        startTime7 = noonToday.replace(hour=14, minute=30)
        delta = 14 + startTime7.date().weekday() - 6
        startTime7 -= datetime.timedelta(days=delta)
        until7 = startTime7 + datetime.timedelta(days=28)
        event7 = pim.CalendarEvent(
                     itsView=parcel.itsView,
                     displayName=_(u"Salsa Class"),
                     startTime=startTime7,
                     duration=datetime.timedelta(hours=1),
                     anyTime=False,
                     read=True,
                     collections=[home, fun],
                     body=_(
u"""Assignment for this week:
.
.
.

Remember to bring:
.
.
.
""")
                 )
        event7.itsItem.changeEditState(pim.Modification.created,
                                       when=startTime7)
        changeTriage(event7, pim.TriageEnum.done)
        makeRecurring(event7, freq='weekly', until=until7)

        # A hack to get this occurrence to appear in the dashboard
        event7.getFirstOccurrence().getNextOccurrence().changeThis()
        for m in sorted(event7.modifications,
                        key=lambda o: pim.EventStamp(o).startTime):
            changeTriage(m, m._triageStatus)

        # OOTB item #8: Brunch potluck...
        startTime8 = datetime.datetime.combine(
                        getDayInThisWeek(6),
                        datetime.time(11, 0, tzinfo=noonToday.tzinfo)
                    )
        
        event8 = pim.CalendarEvent(
                     itsView=parcel.itsView,
                     displayName=_(u"Brunch potluck..."),
                     startTime=startTime8,
                     duration=datetime.timedelta(hours=2),
                     anyTime=False,
                     read=True,
                     collections=[home, fun],
                     body=_(
u"""Directions
.
.
.

Ideas for games to bring...
.
.
.

Sign up to bring food...
.
.
.
"""),
                )
        changeTriage(event8, event8.autoTriage())
        event8.itsItem.changeEditState(pim.Modification.created)

        # OOTB Item #9: Ideas for presents
        item9 = pim.Note(
                    itsView=parcel.itsView,
                    displayName=_(u"Ideas for presents"),
                    read=True,
                    collections=[home],
                    body=_(
u"""Maintain a list of possible presents for family, friends and colleagues so you're never short on ideas!
.
.
.
"""),
                )
        changeTriage(item9, pim.TriageEnum.later)
        item9.changeEditState(pim.Modification.edited)

        # OOTB Item #10: Thank you notes
        item10 = pim.Note(
                     itsView=parcel.itsView,
                     displayName=_(u"Thank you notes"),
                     read=True,
                     collections=[home],
                     body=_(
u"""Who do you need to write thank you notes to? and for what reason?
.
.
.


"""),
                )

        changeTriage(item10, pim.TriageEnum.later)
        item10.changeEditState(pim.Modification.created)

        # OOTB Item #11: Movie list
        item11 = pim.Note(
                     itsView=parcel.itsView,
                     displayName=_(u"Movie list"),
                     read=True,
                     collections=[fun, home],
                     body=_(
u"""Movies you want to see:

.
.
.
"""),
                )

        changeTriage(item11, pim.TriageEnum.later)
        item11.changeEditState(pim.Modification.created)

        # OOTB Item #12: Book list
        item12 = pim.Note(
                     itsView=parcel.itsView,
                     displayName=_(u"Book list"),
                     read=True,
                     collections=[fun, home],
                     body=_(
u"""Book recommendations you've been meaning to follow up on:

.
.
.
"""),
                )

        changeTriage(item12, pim.TriageEnum.later)
        item12.changeEditState(pim.Modification.created)

        # OOTB Item #13: File taxes
        startTime13 = noonToday.replace(month=4, day=15)
        alarmTime13 = startTime13.replace(day=1)
        if alarmTime13 < noonToday:
            alarmTime13 = alarmTime13.replace(year=alarmTime13.year + 1)
            startTime13 = startTime13.replace(year=startTime13.year + 1)

        event13 = pim.CalendarEvent(
                      itsView=parcel.itsView,
                      startTime=startTime13,
                      displayName=_(u"File taxes!"),
                      read=True,
                      collections=[home],
                      body=_(
u"""What forms do you have in hand?
.
.
.

What are you missing?
.
.
.

Questions for your accountant?
.
.
.
"""),
                  )

        pim.TaskStamp(event13).add()
        event13.itsItem.changeEditState(pim.Modification.created)
        changeTriage(event13, pim.TriageEnum.later)
        event13.itsItem.userReminderTime = alarmTime13

        # OOTB Item #14: Class Trip: Exhibit on Sound!
        location14 = pim.Location.update(parcel, "Exploratorium",
            displayName="Exploratorium",
        )

        startTime14 = datetime.datetime.combine(
                        getDayInThisWeek(6),
                        datetime.time(15, tzinfo=noonToday.tzinfo))
        
        event14 = pim.CalendarEvent(
                      itsView=parcel.itsView,
                      startTime=startTime14,
                      displayName=_(u"Class Trip: Exhibit on Sound!"),
                      read=True,
                      location=location14,
                      collections=[fun],
                      body=_(
u"""Directions...
.
.
.
"""),
                  )
        event14.itsItem.changeEditState(pim.Modification.edited,
                                        when=startTime14)
        changeTriage(event14, pim.TriageEnum.done)

        # OOTB Item #15: Download Chandler!
        note15 = pim.Note(
                     itsView= parcel.itsView,
                     displayName=_(u"Download Chandler!"),
                     read=True,
                 )
        dashboard.add(note15)
        done15 = datetime.datetime.now(parcel.itsView.tzinfo.default)
        done15 -= datetime.timedelta(minutes=5)
        done15 = done15.replace(second=0, microsecond=0)
        changeTriage(note15, pim.TriageEnum.done)
        note15.changeEditState(pim.Modification.edited, when=done15)
        
        # Set up sharing for holidays
        share = sharing.Share(itsView=parcel.itsView, mode='get',
                              contents=holidays, established=True)
        filters = set(['cid:[email protected]', 
                       'cid:[email protected]', 'cid:[email protected]',
                       'cid:[email protected]',
                       'cid:[email protected]'])
        share.conduit = sharing.WebDAVMonolithicRecordSetConduit(itsParent=share,
                            host=u'hub.chandlerproject.org',
                            port=443,
                            sharePath=u'webcal/collection',
                            shareName=u'7febe2f4-324c-11dd-d9e4-0016cbca6aed?ticket=01q75n1sy0',
                            useSSL=True,
                            filters=filters,
                            translator=sharing.SharingTranslator,
                            serializer=sharing.ICSSerializer)
        share.conduit.ticketReadOnly = share.conduit.ticket
        sharing.SharedItem(share.contents).add()
        sharing.SharedItem(share.contents).shares.append(share)


    # Set up the main web server
    from osaf import webserver

    startup.Startup.update(parcel, "startServers",
        invoke = "osaf.webserver.start_servers"
    )

    webserver.Server.update(parcel, "mainServer",
        # Port to listen on.  1888 was the year Raymond Chandler was born.
        port=1888,

        # This path specifies the "doc root" of this web server, and is
        # relative to webserver/servers, but you may also put in an
        # absolute path if you wish.
        #
        path=unicode(os.path.join("parcels", "osaf", "app", "webhome")),

        resources = [
            webserver.Resource.update(parcel, "lobsResource",
                displayName=u"Lob Server",
                location=u"lobs",
                resourceClass=schema.importString(
                    "osaf.servlets.lobviewer.LobViewerResource"
                ),
            ),
            webserver.Resource.update(parcel, "photoResource",
                displayName=u"Photo Viewer",
                location=u"photos",
                resourceClass=schema.importString(
                    "osaf.servlets.photo.PhotosResource"
                ),
            ),
            webserver.Resource.update(parcel, "repoResource",
                displayName=u"Repository Viewer",
                location=u"repo",
                resourceClass=schema.importString(
                    "osaf.servlets.repo.RepoResource"
                ),
                autoView=False
            ),
            webserver.Resource.update(parcel, "prefResource",
                displayName=u'Preference Editor',
                location=u"prefs",
                resourceClass=schema.importString(
                    "osaf.servlets.prefs.PrefResource"
                ),
                autoView=False
            ),
            webserver.Resource.update(parcel, "xmlrpcResource",
                displayName=u'XML-RPC Service',
                location=u"xmlrpc",
                resourceClass=schema.importString(
                    "osaf.servlets.xmlrpc.XmlRpcResource"
                ),
                autoView=False
            ),
        ]
    )

    from osaf.app import updates
    
    # Subtract 15 minutes from lastRun so that in a week's
    # time we don't conflict with the "compact" trask.
    updates.UpdateCheckTask.update(
        parcel, 'updateCheckTask',
        interval=datetime.timedelta(days=1),
        lastRun=datetime.datetime.now() - datetime.timedelta(minutes=15)
    )

    # Compact task should come last
    from osaf.app import compact
    compact.CompactTask.update(parcel, 'compactTask')
示例#17
0
    def runTest(self):
        self.setUp()

        inFile = self.getTestResourcePath('stateless.ics')
        dir = os.path.dirname(inFile)
        outFile = os.path.join(dir, 'tmp_stateless.ics')



        # Both status and reminders filters active

        filters = [
            'cid:[email protected]',
            'cid:[email protected]',
        ]

        coll = sharing.importFile(self.views[0], inFile, filters=filters)

        for item in coll:
            uuidStr = item.icalUID
            self.assertEquals(item.displayName, items[uuidStr][0])
            self.assert_(not item.reminders)
            event = pim.EventStamp(item)
            self.assertEquals(event.transparency, 'confirmed')


        # reminders filters active

        filters = [
            'cid:[email protected]',
        ]

        coll = sharing.importFile(self.views[0], inFile, filters=filters)

        for item in coll:
            uuidStr = item.icalUID
            self.assertEquals(item.displayName, items[uuidStr][0])
            self.assert_(not item.reminders)
            event = pim.EventStamp(item)
            self.assertEquals(event.transparency, items[uuidStr][1])


        # No filters active

        coll = sharing.importFile(self.views[0], inFile)

        for item in coll:
            uuidStr = item.icalUID
            self.assertEquals(item.displayName, items[uuidStr][0])
            if items[uuidStr][2] is None:
                self.assert_(not item.reminders)
            else:
                self.assertEquals(list(item.reminders)[0].delta,
                    items[uuidStr][2])

            event = pim.EventStamp(item)
            self.assertEquals(event.transparency, items[uuidStr][1])


        if os.path.exists(outFile):
            os.remove(outFile)

        try:
            # Export using reminders filter
            filters = ['cid:[email protected]']
            sharing.exportFile(self.views[0], outFile, coll, filters=filters)

            # Import using no filters; verify reminders not set on items
            coll = sharing.importFile(self.views[1], outFile)

            for item in coll:
                uuidStr = item.icalUID
                self.assertEquals(item.displayName, items[uuidStr][0])
                self.assert_(not item.reminders)
                event = pim.EventStamp(item)
                self.assertEquals(event.transparency, items[uuidStr][1])

        finally:
            if os.path.exists(outFile):
                os.remove(outFile)