kuba's comment - add current project name as argument in the get_container_data and make sure the scene inventory won't show Entity N/A as name and version

This commit is contained in:
Kayla Man 2024-11-19 15:45:27 +08:00
parent 004e9626ee
commit 3078ba2a23
3 changed files with 14 additions and 12 deletions

View file

@ -4,7 +4,7 @@ from ayon_core.lib.events import QueuedEventSystem
from ayon_core.host import HostBase
from ayon_core.pipeline import (
registered_host,
get_current_context
get_current_context,
)
from ayon_core.tools.common_models import HierarchyModel, ProjectsModel

View file

@ -135,8 +135,7 @@ class InventoryModel(QtGui.QStandardItemModel):
self._clear_items()
items_by_repre_id = collections.defaultdict(list)
item_by_repre_id_by_project_id = collections.defaultdict(
lambda: collections.defaultdict(set))
repre_ids_by_project = collections.defaultdict(set)
for container_item in container_items:
# if (
# selected is not None
@ -146,17 +145,20 @@ class InventoryModel(QtGui.QStandardItemModel):
project_name = container_item.project_name
repre_id = container_item.representation_id
items_by_repre_id[repre_id].append(container_item)
item_by_repre_id_by_project_id[project_name][repre_id].add(container_item)
repre_ids_by_project[project_name].add(repre_id)
repre_id = set(items_by_repre_id.keys())
repre_info_by_id = {}
repre_id = set()
for project_name, repre_ids in item_by_repre_id_by_project_id.items():
repre_ids = set(items_by_repre_id.keys())
for project_name, repre_ids in repre_ids_by_project.items():
repre_info = self._controller.get_representation_info_items(
project_name, repre_ids
)
repre_info_by_id.update(repre_info)
repre_id.update(repre_ids)
product_ids = {
repre_info.product_id
for repre_info in repre_info_by_id.values()
if repre_info.is_valid
}
project_products = collections.defaultdict(set)
for container_item in container_items:

View file

@ -5,7 +5,6 @@ import ayon_api
from ayon_api.graphql import GraphQlQuery
from ayon_core.host import ILoadHost
from ayon_core.pipeline import get_current_project_name
from ayon_core.tools.common_models.projects import StatusStates
@ -105,7 +104,7 @@ class ContainerItem:
self.project_name = project_name
@classmethod
def from_container_data(cls, container):
def from_container_data(cls, current_project_name, container):
return cls(
representation_id=container["representation"],
loader_name=container["loader"],
@ -113,7 +112,7 @@ class ContainerItem:
object_name=container["objectName"],
item_id=uuid.uuid4().hex,
project_name=container.get(
"project_name", get_current_project_name()
"project_name", current_project_name
)
)
@ -368,7 +367,8 @@ class ContainersModel:
invalid_ids_mapping = {}
for container in containers:
try:
item = ContainerItem.from_container_data(container)
current_project_name = self._controller.get_current_project_name()
item = ContainerItem.from_container_data(current_project_name, container)
repre_id = item.representation_id
try:
uuid.UUID(repre_id)