def doesUserExist(userEmail): user = User.objects.filter(userEmail=userEmail) if(len(user)==0): Error.userDoesNotExist(userEmail) return False elif(len(user)==1): return True else: Error.userAlreadyExists(userEmail) return False
def addUser(userName, userEmail, userID, filters): user = User.objects.filter(userEmail=userEmail) #Checks to see if there are any other users with this email in the database already if(len(user)==0):#if not then add a new user user = User(userName=userName,userEmail=userEmail,userID=userID) user.save() for key in filters.keys(): user.filter_set.create(filterName=key, filterKeywords=filters[key]) else: #otherwise throw error Error.userAlreadyExists(userEmail)