Skip to content

Commit

Permalink
Merge pull request getavalon#15 from pypeclub/hotfix/backward_comp_fix
Browse files Browse the repository at this point in the history
Hotfix/backward comp fix
  • Loading branch information
iLLiCiTiT authored Feb 10, 2020
2 parents 473d949 + 6b9e582 commit 535db5b
Showing 1 changed file with 25 additions and 27 deletions.
52 changes: 25 additions & 27 deletions launcher/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def __init__(self, root, parent=None):
roles=[
"_id",
"name",
"type",
"label",
"icon",
"group"
Expand Down Expand Up @@ -260,6 +261,7 @@ def init(self):
dict({
"_id": project["_id"],
"icon": DEFAULTS["icon"]["project"],
"type": project["type"],
"name": project["name"],
}, **project["data"])
for project in sorted(io.projects(), key=lambda x: x['name'])
Expand Down Expand Up @@ -313,12 +315,13 @@ def on_project_changed(self, index):
self._model.push([dict({
"_id": asset["_id"],
"name": asset["name"],
"type": asset["type"],
"icon": DEFAULTS["icon"]["asset"]
}) for asset in assets])

else:
self._model.push([dict({
"name": silo, "icon": DEFAULTS["icon"]["silo"]
"name": silo, "icon": DEFAULTS["icon"]["silo"], "type": "silo"
}) for silo in sorted(silos)])

frame = project
Expand Down Expand Up @@ -371,28 +374,21 @@ def on_silo_changed(self, index):
if not doc["data"].get("visible", True):
continue

if "visualParent" not in doc["data"]:
valid_docs.append(
dict(
{
"_id": doc["_id"],
"name": doc["name"],
"icon": DEFAULTS["icon"]["asset"]
},
**doc["data"]
)
)
else:
data = dict(
{
"_id": doc["_id"],
"name": doc["name"],
"icon": DEFAULTS["icon"]["asset"]
},
**doc["data"]
)
data = {
"_id": doc["_id"],
"name": doc["name"],
"icon": DEFAULTS["icon"]["asset"]
}
data.update(doc["data"])

if "visualParent" in doc["data"]:
vis_par = doc["data"]["visualParent"]
if vis_par is not None:
continue

if "label" not in data:
data["label"] = doc["name"]
valid_docs.append(data)
valid_docs.append(data)

frame["environment"]["silo"] = name
frame["name"] = name
Expand All @@ -403,16 +399,16 @@ def on_silo_changed(self, index):
self.pushed.emit(name)

def on_asset_changed(self, index):
# Backwards compatible way
_type = model.data(index, "type")
if _type == "silo":
return self.on_silo_changed(index)

name = model.data(index, "name")
entity = io.find_one({
"type": "asset",
"name": name
})
# Backwards compatible way
if entity is None:
self.on_silo_changed(index)
return

api.Session["AVALON_ASSET"] = name

frame = self.current_frame()
Expand Down Expand Up @@ -501,6 +497,7 @@ def on_asset_changed(self, index):
{
"_id": doc["_id"],
"name": doc["name"],
"type": doc["type"],
"icon": DEFAULTS["icon"]["asset"]
},
**doc["data"]
Expand All @@ -512,6 +509,7 @@ def on_asset_changed(self, index):
{
"_id": doc["_id"],
"name": doc["name"],
"type": doc["type"],
"icon": DEFAULTS["icon"]["asset"]
},
**doc["data"]
Expand Down

0 comments on commit 535db5b

Please sign in to comment.