예제 #1
0
def formatNewEvent(date, startTime, endTime, summary, region, seshtype,
                   difficulty, seats):
    contactList = contactUtils.getContacts()
    regionObj = contactUtils.getRegion()
    startDate = DateUtils.formatEventDate(date + "/" + startTime)
    endDate = DateUtils.formatEventDate(date + "/" + endTime)
    summary = seats + " Seats - " + difficulty + " - " + summary + " - " + region + " (" + seshtype + ")"
    owner = contactList[regionObj[region][0]][0]
    location = regionObj[region][1]
    attendees = [{"email": owner}]
    description = ""
    for seat in range(1, int(seats) + 1):
        description += str(seat) + ".\n"
    description += "\n\n\n\rWaitList:"
    finalFormat = {
        "start": {
            "dateTime": startDate + "-05:00"
        },
        "end": {
            "dateTime": endDate + "-05:00"
        },
        "summary": summary,
        "description": description,
        "attendees": attendees,
        "location": location,
        'reminders': {
            'useDefault': True
        }
    }
    return finalFormat
예제 #2
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,"")
예제 #3
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]
예제 #4
0
    def getSessionsByUser(self, message, name):
        def sortByDate(elem):
            return elem["start"]
        contactobj = contactUtils.getContacts()
        playerDict = {x:y for (x,y) in contactobj.items() if name in y}

        events = self.calendar.listEvent()
        events = sorted([x for x in events if "Available" not in x["summary"]], key=sortByDate)
        events = [x for x in events if DateUtils.compareDate(x["start"])]
        print(events)
        print(playerDict)
        return ""
예제 #5
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])
예제 #6
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
예제 #7
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]
예제 #8
0
 def getEventsForTheWeek(self, date):
     eventList = self.calendar.listEvent()
     beginningOfWeek = DateUtils.getBeginningOfWeek(date)
     eventList = [x for x in eventList if x["start"].date() >= beginningOfWeek and "Available" not in x["summary"] and "Tier" in x["summary"] and x["end"].date() <= DateUtils.getEndOfWeek(date)]
     return eventList