Esempio n. 1
0
 def isWaitList(self, date, region, email):
     sessionArray = []
     def createSessionString(eventArray):
         if len(eventArray) > 1:
             plural = "s"
         else: 
             plural = ""
         string = region + " session" + plural + " on "
         for event in range(0,len(eventArray)):
             dateString = DateUtils.rewriteDate(eventArray[event]["start"])
             if event == (len(eventArray) - 1) and len(eventArray) > 1:
                 string = string[:-2]
                 string += " and " + dateString + "."
             else:
                 string += dateString + ", "
         return string
     dateInDate = DateUtils.dayMonthToDateTime(date).date()
     within48Hours = DateUtils.isWithinTwoDays(dateInDate)
     if within48Hours:
         return (False,"")
     eventsForWeek = self.getEventsForTheWeek(dateInDate)
     eventsForRegion = [x for x in eventsForWeek if region in x["summary"]]
     for event in eventsForRegion:
         for attendee in event["attendees"]:
             if email == attendee["email"]:
                 sessionArray.append(event)
     if len(sessionArray) > 0:
         return (True, createSessionString(sessionArray))
     return (False,"")
Esempio n. 2
0
 def removeAvailability(self, date, region):
     availability = self.calendar.listEvents(True)
     dm = contactUtils.getRegion()[region][0].split(" ")[0]
     date = DateUtils.rewriteDate(DateUtils.dayMonthToDateTime(date))
     availability = [x for x in availability if dm in x[0] and x[1] == date]
     try:
         eventToRemove = availability[0][2]
     except:
         return True
     success = self.calendar.removeEvent(eventToRemove)
     if success[0] == True:
         return True
     else:
         return success[1]
Esempio n. 3
0
 def removeUser(self, message, name, admin=False):
     contactobj = contactUtils.getContacts()
     if admin:
         playerDict = {x:y for (x,y) in contactobj.items() if name in x}
         pattern = re.compile(".*removemem! " + name + ",")
     else:
         playerDict = {x:y for (x,y) in contactobj.items() if name in y}
         pattern = re.compile(".*remove!")
     fullName = list(playerDict)[0]
     email = playerDict[fullName][0]
     tempMessage = re.sub(pattern,"", message.content)
     messageArray = [x.strip() for x in tempMessage.split(",")]
     try:
         date, region = messageArray[0], messageArray[1]
     except:
         return (False, "Invalid")
     isAlreadySignedUp = self.isAlreadySignedUp(date,region,email)
     if not isAlreadySignedUp:
         return (False,"Empty")
     else:
         self.removeUserFromCalendar(fullName, date, region)
         return (True, [DateUtils.rewriteDate(DateUtils.dayMonthToDateTime(date)), region])
Esempio n. 4
0
 def findEventByDateAndRegion(self, date, region):
     date = DateUtils.dayMonthToDateTime(date).date()
     eventList = self.calendar.listEvent()
     eventList = [x for x in eventList if region in x["summary"]]
     eventList = [x for x in eventList if date == x["start"].date()]
     return eventList[0]