Refactor - use values from context if available

Remove unnecessary keys from data
This commit is contained in:
Petr Kalis 2023-02-08 16:18:45 +01:00
parent 60c6a61779
commit 6894e17bbc
2 changed files with 32 additions and 17 deletions

View file

@ -1468,23 +1468,21 @@ class RepresentationWidget(QtWidgets.QWidget):
repre_ids = []
data_by_repre_id = {}
selected_side = action_representation.get("selected_side")
site_name = "{}_site_name".format(selected_side)
is_sync_loader = tools_lib.is_sync_loader(loader)
for item in items:
item_id = item.get("_id")
repre_ids.append(item_id)
repre_id = item["_id"]
repre_ids.append(repre_id)
if not is_sync_loader:
continue
site_name = "{}_site_name".format(selected_side)
data_site_name = item.get(site_name)
if not data_site_name:
continue
data_by_repre_id[item_id] = {
"_id": item_id,
"site_name": data_site_name,
"project_name": self.dbcon.active_project()
data_by_repre_id[repre_id] = {
"site_name": data_site_name
}
repre_contexts = get_repres_contexts(repre_ids, self.dbcon)
@ -1574,8 +1572,8 @@ def _load_representations_by_loader(loader, repre_contexts,
version_name = version_doc.get("name")
try:
if data_by_repre_id:
_id = repre_context["representation"]["_id"]
data = data_by_repre_id.get(_id)
repre_id = repre_context["representation"]["_id"]
data = data_by_repre_id.get(repre_id)
options.update(data)
load_with_repre_context(
loader,