def emailRecovery(address): key = passHandler.getHash(address) query = "insert into passReset(userID, validator) values (%s, %s)" values = (address, key) sql.createQuery(query, values) # mailjet.mailReset(address, key) return
def attendeeSubmit(userEmail, eventID, userName, timeList): # Is attendee name needed? query = "insert into Responses(userEmail, eventID, userName, timeSlot) values (%s, %s, %s, %s)" for timeSlot in timeList: values = (userEmail, eventID, userName, timeSlot) sql.createQuery(query, values) return attendeeAvailability(userEmail, eventID)
def attendeeEdit(userEmail, eventID, userName, timeList): # step 1: fetch auxiliary values # step 2: remove existing entries query = "delete from Responses where userEmail = %s and eventID = %s" values = (userEmail, eventID) sql.createQuery(query, values) # step 3: add new entries from array of times # TODO: Implement for each loop return attendeeSubmit(userEmail, eventID, userName, timeList)
def finalizeEvent(eventID, timeSlot): query = "select userEmail from Responses where eventID = %s and timeSlot = %s" values = (eventID, timeSlot) results = sql.getQueryResults(query, values) for res in results: emailer.eventConfirm(res[0], timeSlot) query = "delete from Responses where eventID = %s and timeSlot !=%s" values = (eventID, timeSlot) sql.createQuery(query, values)
def createUser(email, fName, lName, rawPass): exists = getUser(email) if exists == (): hashedPass = passHandler.getHash(rawPass) query = "insert into Users(userID,FName,LName,Pass) values (%s,%s,%s,%s)" values = (email, fName, lName, hashedPass) sql.createQuery(query, values) return True else: return False
def resetPassword(key, email, newPass): if (checkForReset(key, email)): query = "delete from passReset where validator = %s" values = (key, ) sql.createQuery(query, values) pwd = passHandler.getHash(newPass) query = "update Users set Pass = %s where userID = %s" values = (email, pwd) sql.createQuery(query, values) return True return False
def createEvent(eName, duration, isRecurring, creator, grain, timeList): now = datetime.now() schedName = eName dur = duration recurFlag = isRecurring toHash = eName + str(dur) + str(recurFlag) + str(now) hashed = hashlib.md5(str.encode(toHash)) eventID = hashed.hexdigest() query = "insert into Event(eventID, eventName, eventDuration, eventRecurs, eventShared, eventFrequency, eventCreator, eventCreationTime, eventGranularity) values (%s, %s, %s, %s, %s, %s, %s, %s, %s)" values = (eventID, schedName, dur, recurFlag, shared, frequency, creator, now, grain) sql.createQuery(query, values) if (recurFlag == 1): for t in timeList: query = "insert into Recurring (eventID, day, timeSlot) values (%s, %s, %s)" values = (eventID, t.weekday(), t.time()) sql.createQuery(query, values) else: for t in timeList: query = "insert into OneTime (eventID, date, timeSlot) values (%s, %s, %s)" values = (eventID, t.date(), t.time()) sql.createQuery(query, values) return eventID
def deleteUser(userID): eventHandler.deleteEventByCreator(userID) query = "delete from Users where userID=%s" values = (userID, ) sql.createQuery(query, values)
def updatePassword(email, oldPass, newPass): if (passHandler.confirmPass(email, oldPass)): pwd = passHandler.getHash(newPass) query = "update Users set Pass = %s where userID = %s" values = (email, pwd) sql.createQuery(query, values)
def editName(fName, lName, email): query = "update Users set FName = %s, LName = %s where userID = %s" values = (fName, lName, email) sql.createQuery(query, values)
def editLastName(lName, email): query = "update Users set LName = %s where userID = %s" values = (lName, email) sql.createQuery(query, values)
def deleteEventByCreator(eventCreator): query = "delete from Event where eventCreator=%s" values = (eventCreator, ) sql.createQuery(query, values)
def deleteEventByID(eventID): query = "delete from Event where eventID=%s" values = (eventID, ) sql.createQuery(query, values)