def METHOD_NAME(user, level):
    if user.is_anonymous:
        return False
    elif level.owner == user.userprofile:
        return True
    elif hasattr(user.userprofile, "teacher"):
        return can_play_or_delete_level(user, level)
    return False