code tweaks - kuba's comment

This commit is contained in:
Kayla Man 2024-11-18 19:18:50 +08:00
parent 8965a88594
commit 0866c00201
3 changed files with 12 additions and 34 deletions

View file

@ -53,7 +53,7 @@ class InventoryModel(QtGui.QStandardItemModel):
"Object name",
"Active site",
"Remote site",
"Project"
"Project",
]
name_col = column_labels.index("Name")
version_col = column_labels.index("Version")
@ -142,10 +142,7 @@ class InventoryModel(QtGui.QStandardItemModel):
# and container_item.item_id not in selected
# ):
# continue
project_name = (
container_item.project_name or
self._controller.get_current_project_name()
)
project_name = container_item.project_name
repre_id = container_item.representation_id
items_by_repre_id[repre_id].append(container_item)
repre_ids_by_project[project_name].add(repre_id)
@ -166,10 +163,7 @@ class InventoryModel(QtGui.QStandardItemModel):
project_products = collections.defaultdict(set)
for container_item in container_items:
representation_id = container_item.representation_id
project_name = (
container_item.project_name or
self._controller.get_current_project_name()
)
project_name = container_item.project_name
repre_info = repre_info_by_id.get(representation_id)
if repre_info and repre_info.is_valid:
product_id = repre_info.product_id

View file

@ -5,6 +5,7 @@ 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
@ -111,7 +112,9 @@ class ContainerItem:
namespace=container["namespace"],
object_name=container["objectName"],
item_id=uuid.uuid4().hex,
project_name=container.get("project_name", None)
project_name=container.get(
"project_name", get_current_project_name()
)
)

View file

@ -195,10 +195,7 @@ class SceneInventoryView(QtWidgets.QTreeView):
repre_ids_by_project = collections.defaultdict(set)
for container_item in container_items_by_id.values():
repre_id = container_item.representation_id
project_name = (
container_item.project_name or
self._controller.get_current_project_name()
)
project_name = container_item.project_name
repre_ids_by_project[project_name].add(repre_id)
repre_info_by_id = {}
for project_name, repre_ids in repre_ids_by_project.items():
@ -219,10 +216,7 @@ class SceneInventoryView(QtWidgets.QTreeView):
version_ids = set()
for container_item in container_items_by_id.values():
repre_id = container_item.representation_id
project_name = (
container_item.project_name or
self._controller.get_current_project_name()
)
project_name = container_item.project_name
repre_info = repre_info_by_id.get(repre_id)
if repre_info and repre_info.is_valid:
filtered_items.append(container_item)
@ -754,10 +748,7 @@ class SceneInventoryView(QtWidgets.QTreeView):
repre_ids_by_project = collections.defaultdict(set)
for container_item in container_items_by_id.values():
repre_id = container_item.representation_id
project_name = (
container_item.project_name or
self._controller.get_current_project_name()
)
project_name = container_item.project_name
repre_ids_by_project[project_name].add(repre_id)
repre_info_by_id = {}
for project_name, repre_ids in repre_ids_by_project.items():
@ -773,10 +764,7 @@ class SceneInventoryView(QtWidgets.QTreeView):
product_ids_by_project = collections.defaultdict(set)
for container_item in container_items_by_id.values():
repre_id = container_item.representation_id
project_name = (
container_item.project_name or
self._controller.get_current_project_name()
)
project_name = container_item.project_name
repre_info = repre_info_by_id.get(repre_id)
if not repre_info or not repre_info.is_valid:
continue
@ -972,10 +960,6 @@ class SceneInventoryView(QtWidgets.QTreeView):
repre_ids_by_project = collections.defaultdict(set)
for container_item in containers_items_by_id.values():
project_name = container_item.project_name
project_name = (
container_item.project_name or
self._controller.get_current_project_name()
)
repre_id = container_item.representation_id
repre_ids_by_project[project_name].add(repre_id)
@ -989,10 +973,7 @@ class SceneInventoryView(QtWidgets.QTreeView):
product_ids_by_project = collections.defaultdict(set)
for container_item in containers_items_by_id.values():
repre_id = container_item.representation_id
project_name = (
container_item.project_name or
self._controller.get_current_project_name()
)
project_name = container_item.project_name
repre_info = repre_info_by_id.get(repre_id)
if not repre_info or not repre_info.is_valid:
continue