Example #1
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]
Example #2
0
 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
Example #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])