From 3eba2baddfd18ed8d365bc2b9b7b53163778ad4c Mon Sep 17 00:00:00 2001 From: Marica Antonacci Date: Tue, 24 Oct 2023 11:37:44 +0200 Subject: [PATCH] Manage missing visibility in metadata --- app/home/routes.py | 10 +++++----- app/lib/ToscaInfo.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/home/routes.py b/app/home/routes.py index 62f62bf4e..f1477b032 100644 --- a/app/home/routes.py +++ b/app/home/routes.py @@ -121,18 +121,18 @@ def login(): def set_template_access(tosca, user_groups, active_group): info = {} for k, v in tosca.items(): - visibility = v.get("metadata").get("visibility").get("type") + visibility = v.get("metadata").get("visibility") if "visibility" in v.get("metadata") else {"type": "public"} - if visibility != "public": - allowed_groups = v.get("metadata").get("visibility").get("groups") - regex = False if "groups_regex" not in v.get("metadata").get("visibility") else v.get("metadata").get("visibility").get("groups_regex") + if visibility.get("type") != "public": + allowed_groups = visibility.get("groups") + regex = False if "groups_regex" not in visibility else visibility.get("groups_regex") if regex: access_locked = not re.match(allowed_groups, active_group) else: access_locked = True if active_group not in allowed_groups else False - if (visibility == "private" and not access_locked) or visibility == "protected": + if (visibility.get("type") == "private" and not access_locked) or visibility.get("type") == "protected": v["metadata"]["access_locked"] = access_locked info[k] = v else: diff --git a/app/lib/ToscaInfo.py b/app/lib/ToscaInfo.py index cf6722c40..103a65473 100644 --- a/app/lib/ToscaInfo.py +++ b/app/lib/ToscaInfo.py @@ -90,9 +90,9 @@ def extracttoscainfo(self, template, tosca): "description": "TOSCA Template", "metadata": { "icon": "https://cdn4.iconfinder.com/data/icons/mosaicon-04/512/websettings-512.png", - "visibility": { "type": "public", "groups": ".*", "groups_regex": True }, - "require_ssh_key": True, - "template_type": "" + "visibility": { "type": "public" }, + "require_ssh_key": True, + "template_type": "" }, "enable_config_form": False, "inputs": {},