def get_permission_codes(permission_resources):
    """
    Generate a list of resource code that the user can access to
    :param permission_resources: Resources that user can access to
    :return: a list of resource code that the user can access to
    """
    permission_codes = []

    for resource in permission_resources:
        permission_codes.append(resource.code)
        parent = resource.parent
        while parent:
            permission_codes.append(parent.code)
            parent = parent.parent
    return set(permission_codes)