Skip to content

Commit

Permalink
Manage missing visibility in metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
maricaantonacci committed Oct 24, 2023
1 parent 413b4f3 commit 3eba2ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions app/home/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions app/lib/ToscaInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
Expand Down

0 comments on commit 3eba2ba

Please sign in to comment.