def is_username_available(cls, username): ''' This method checks to see if an username has been registered by another user Args: username: The username to be checked for availability Returns: False is the username has been used by another user True if otherwise ''' if username is None: return False key = 'username_available_' + username rv = r.get(key) if rv is not None: return rv if username is not None and \ User.objects(name=username).first() is None: r.set(key, False) return True else: return False
def is_email_available(cls, email): ''' This method checks to see if an email has been previously used or registered by another user Args: email: The email to be checked for availability Returns: False is the email has been used by another user True if otherwise ''' if email is None: return False key = 'email_available_' + email rv = r.get(key) if rv is not None: return rv if email is not None and User.objects(email=email).first() is None: r.set(key, False) return True else: return False