(username)
return valid, message, error_code
:param username: ex: jordan@testapp-9.commcarehq.org
    :return
        valid: is True by default but is set to False for inactive/deleted user
        error_code: mapping in app_string for the user
        default_response: english description of the error to be used in case error_code missing
:param username: ex: jordan
: param username : ex : jordan
def ensure_active_user_by_username(username):
    """
    :param username: ex: jordan@testapp-9.commcarehq.org
    :return
        valid: is True by default but is set to False for inactive/deleted user
        error_code: mapping in app_string for the user
        default_response: english description of the error to be used in case error_code missing
    """
    ccu = CommCareUser.get_by_username(username)
    valid, message, error_code = True, None, None
    if ccu and not ccu.is_active:
        valid, message, error_code = False, 'Your account has been deactivated, please contact your domain admin '\
                                            'to reactivate', 'user.deactivated'
    elif get_deleted_user_by_username(CommCareUser, username):
        valid, message, error_code = False, 'Your account has been deleted, please contact your domain admin to '\
                                            'request for restore', 'user.deleted'
    return valid, message, error_code
def ensure_active_user_by_username ( username ) : ccu = CommCareUser . get_by_username ( username ) valid , message , error_code = True , None , None if ccu and not ccu . is_active : valid , message , error_code = False , 'Your account has been deactivated, please contact your domain admin ' 'to reactivate' , 'user.deactivated' elif get_deleted_user_by_username ( CommCareUser , username ) : valid , message , error_code = False , 'Your account has been deleted, please contact your domain admin to ' 'request for restore' , 'user.deleted' return valid , message , error_code