コード例 #1
0
 def createCalendarData(self, ownerId=None, ownerType=None, permissions=None, data=None):
     if ownerId is None:
         logWarning("NO OWNER ID WAS GIVEN WHEN ATTEMPTING TO LOOK UP CALENDAR")
         return None
     if data is None:
         data = Calendar().to_ical()
     result = self.DB_BRIDGE.getCalendarFromOwnerId(ownerId)
     if result is None:
         result = DBCalendarData()
     result.setCalendarData(ownerId, ownerType, permissions, data)
     result.saveToDB()
     return result
コード例 #2
0
    def setUp(self):
        self.icalReader = ICalReader()

        self.calendarData = DBCalendarData()
        self.calendarData.ownerId = 'dummyOwner'
        self.calendarData.ownerType = STUDENT_OWNER_TYPE
        self.calendarData.accessPermissions = PUBLIC_PERMISSION
        self.calendarData.calendarData = Calendar().to_ical()

        self.dummyTask = DBTask()
        self.dummyTask.displayName = "dummyTaskDisplayName"
        self.dummyTask.name = "dummyTaskName"
        self.dummyTask.taskId = "dummyTaskId"
コード例 #3
0
 def getCalendarFromOwnerId(self, ownerId=None, useCache=True):
     if ownerId is None:
         logWarning("NO OWNER ID WAS GIVEN WHEN ATTEMPTING TO LOOK UP CALENDAR")
         return None
     
     if useCache:
         result = self.calendarCache.get(ownerId, None)
         if result is not None:
             return result;
     
     foundCalendars = DBCalendarData.find_by_index("ownerIdIndex", [])
     calendarData = None
     if len(foundCalendars) == 0:
         logInfo("No calendar found, creating a new calendar for owner:{0}".format(ownerId), 1)
         calendarData = DBCalendarData()
         calendarData.setCalendarData(ownerId)
     elif len(foundCalendars) == 1:
         calendarData = foundCalendars[0]
     elif len(foundCalendars) > 1:
         logWarning("{0} owns more than a single calendar.  Database may be corrupted.  Defaulting to the first value".format(ownerId))
         calendarData = foundCalendars[0]
     self.calendarCache[ownerId] = calendarData
     return calendarData
コード例 #4
0
 def createCalendarData(self,
                        ownerId=None,
                        ownerType=None,
                        permissions=None,
                        data=None):
     if ownerId is None:
         logWarning(
             "NO OWNER ID WAS GIVEN WHEN ATTEMPTING TO LOOK UP CALENDAR")
         return None
     if data is None: data = Calendar().to_ical()
     result = self.DB_BRIDGE.getCalendarFromOwnerId(ownerId)
     if result is None:
         result = DBCalendarData()
     result.setCalendarData(ownerId, ownerType, permissions, data)
     result.saveToDB()
     return result