mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
use project name in site sync calls
This commit is contained in:
parent
7935ed3284
commit
b25715ee2b
3 changed files with 29 additions and 15 deletions
|
|
@ -132,7 +132,6 @@ class InventoryModel(QtGui.QStandardItemModel):
|
||||||
# for debugging or testing, injecting items from outside
|
# for debugging or testing, injecting items from outside
|
||||||
container_items = self._controller.get_container_items()
|
container_items = self._controller.get_container_items()
|
||||||
self._clear_items()
|
self._clear_items()
|
||||||
repre_ids = set()
|
|
||||||
repre_ids_by_project = collections.defaultdict(set)
|
repre_ids_by_project = collections.defaultdict(set)
|
||||||
version_items_by_product_id = collections.defaultdict(dict)
|
version_items_by_product_id = collections.defaultdict(dict)
|
||||||
repre_info_by_id_by_project = collections.defaultdict(dict)
|
repre_info_by_id_by_project = collections.defaultdict(dict)
|
||||||
|
|
@ -146,7 +145,6 @@ class InventoryModel(QtGui.QStandardItemModel):
|
||||||
# continue
|
# continue
|
||||||
project_name = container_item.project_name
|
project_name = container_item.project_name
|
||||||
representation_id = container_item.representation_id
|
representation_id = container_item.representation_id
|
||||||
repre_ids.add(representation_id)
|
|
||||||
repre_ids_by_project[project_name].add(representation_id)
|
repre_ids_by_project[project_name].add(representation_id)
|
||||||
item_by_repre_id_by_project_id[project_name][representation_id].add(container_item)
|
item_by_repre_id_by_project_id[project_name][representation_id].add(container_item)
|
||||||
|
|
||||||
|
|
@ -167,9 +165,13 @@ class InventoryModel(QtGui.QStandardItemModel):
|
||||||
version_items_by_product_id[project_name] = version_items
|
version_items_by_product_id[project_name] = version_items
|
||||||
|
|
||||||
# SiteSync addon information
|
# SiteSync addon information
|
||||||
progress_by_id = self._controller.get_representations_site_progress(
|
progress_by_project = {}
|
||||||
repre_ids
|
for project_name, repre_ids in repre_ids_by_project.items():
|
||||||
)
|
progress_by_id = self._controller.get_representations_site_progress(
|
||||||
|
project_name, repre_ids
|
||||||
|
)
|
||||||
|
progress_by_project[project_name] = progress_by_id
|
||||||
|
|
||||||
sites_info = self._controller.get_sites_information()
|
sites_info = self._controller.get_sites_information()
|
||||||
site_icons = {
|
site_icons = {
|
||||||
provider: get_qt_icon(icon_def)
|
provider: get_qt_icon(icon_def)
|
||||||
|
|
@ -207,6 +209,7 @@ class InventoryModel(QtGui.QStandardItemModel):
|
||||||
root_item = self.invisibleRootItem()
|
root_item = self.invisibleRootItem()
|
||||||
group_items = []
|
group_items = []
|
||||||
for project_name, items_by_repre_id in item_by_repre_id_by_project_id.items():
|
for project_name, items_by_repre_id in item_by_repre_id_by_project_id.items():
|
||||||
|
progress_by_id = progress_by_project[project_name]
|
||||||
for repre_id, container_items in items_by_repre_id.items():
|
for repre_id, container_items in items_by_repre_id.items():
|
||||||
repre_info = repre_info_by_id_by_project[project_name][repre_id]
|
repre_info = repre_info_by_id_by_project[project_name][repre_id]
|
||||||
version_color = None
|
version_color = None
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ class SiteSyncModel:
|
||||||
active_site = self._get_active_site()
|
active_site = self._get_active_site()
|
||||||
remote_site = self._get_remote_site()
|
remote_site = self._get_remote_site()
|
||||||
progress = self.get_representations_site_progress(
|
progress = self.get_representations_site_progress(
|
||||||
representation_ids
|
project_name, representation_ids
|
||||||
)
|
)
|
||||||
for repre_id in representation_ids:
|
for repre_id in representation_ids:
|
||||||
repre_progress = progress.get(repre_id)
|
repre_progress = progress.get(repre_id)
|
||||||
|
|
|
||||||
|
|
@ -413,12 +413,13 @@ class SceneInventoryView(QtWidgets.QTreeView):
|
||||||
|
|
||||||
self._handle_sitesync(menu, valid_repre_ids)
|
self._handle_sitesync(menu, valid_repre_ids)
|
||||||
|
|
||||||
def _handle_sitesync(self, menu, repre_ids):
|
def _handle_sitesync(self, menu, repre_ids_by_project_name):
|
||||||
"""Adds actions for download/upload when SyncServer is enabled
|
"""Adds actions for download/upload when SyncServer is enabled
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
menu (OptionMenu)
|
menu (OptionMenu)
|
||||||
repre_ids (list) of object_ids
|
repre_ids_by_project_name (Dict[str, Set[str]]): Representation
|
||||||
|
ids by project name.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
(OptionMenu)
|
(OptionMenu)
|
||||||
|
|
@ -427,7 +428,7 @@ class SceneInventoryView(QtWidgets.QTreeView):
|
||||||
if not self._controller.is_sitesync_enabled():
|
if not self._controller.is_sitesync_enabled():
|
||||||
return
|
return
|
||||||
|
|
||||||
if not repre_ids:
|
if not repre_ids_by_project_name:
|
||||||
return
|
return
|
||||||
|
|
||||||
menu.addSeparator()
|
menu.addSeparator()
|
||||||
|
|
@ -439,7 +440,10 @@ class SceneInventoryView(QtWidgets.QTreeView):
|
||||||
menu
|
menu
|
||||||
)
|
)
|
||||||
download_active_action.triggered.connect(
|
download_active_action.triggered.connect(
|
||||||
lambda: self._add_sites(repre_ids, "active_site"))
|
lambda: self._add_sites(
|
||||||
|
repre_ids_by_project_name, "active_site"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
upload_icon = qtawesome.icon("fa.upload", color=DEFAULT_COLOR)
|
upload_icon = qtawesome.icon("fa.upload", color=DEFAULT_COLOR)
|
||||||
upload_remote_action = QtWidgets.QAction(
|
upload_remote_action = QtWidgets.QAction(
|
||||||
|
|
@ -448,23 +452,30 @@ class SceneInventoryView(QtWidgets.QTreeView):
|
||||||
menu
|
menu
|
||||||
)
|
)
|
||||||
upload_remote_action.triggered.connect(
|
upload_remote_action.triggered.connect(
|
||||||
lambda: self._add_sites(repre_ids, "remote_site"))
|
lambda: self._add_sites(
|
||||||
|
repre_ids_by_project_name, "remote_site"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
menu.addAction(download_active_action)
|
menu.addAction(download_active_action)
|
||||||
menu.addAction(upload_remote_action)
|
menu.addAction(upload_remote_action)
|
||||||
|
|
||||||
def _add_sites(self, repre_ids, site_type):
|
def _add_sites(self, repre_ids_by_project_name, site_type):
|
||||||
"""(Re)sync all 'repre_ids' to specific site.
|
"""(Re)sync all 'repre_ids' to specific site.
|
||||||
|
|
||||||
It checks if opposite site has fully available content to limit
|
It checks if opposite site has fully available content to limit
|
||||||
accidents. (ReSync active when no remote >> losing active content)
|
accidents. (ReSync active when no remote >> losing active content)
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
repre_ids (list)
|
repre_ids_by_project_name (Dict[str, Set[str]]): Representation
|
||||||
|
ids by project name.
|
||||||
site_type (Literal[active_site, remote_site]): Site type.
|
site_type (Literal[active_site, remote_site]): Site type.
|
||||||
"""
|
|
||||||
|
|
||||||
self._controller.resync_representations(repre_ids, site_type)
|
"""
|
||||||
|
for project_name, repre_ids in repre_ids_by_project_name.items():
|
||||||
|
self._controller.resync_representations(
|
||||||
|
project_name, repre_ids, site_type
|
||||||
|
)
|
||||||
|
|
||||||
self.data_changed.emit()
|
self.data_changed.emit()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue