Improve denied output

This commit is contained in:
Mark Veidemanis 2022-08-27 12:25:54 +01:00
parent c4f17dd5fb
commit 0eda404732
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 5 additions and 6 deletions

View File

@ -320,16 +320,15 @@ def query_results(
denied_t = hash_lookup(request.user, tags)
denied.extend(denied_t)
message = []
message = "Permission denied: "
for x in denied:
if isinstance(x, SearchDenied):
message.append(f"Permission denied to search by {x.key}: {x.value}")
message += f"Search({x.key}: {x.value}) "
elif isinstance(x, LookupDenied):
message.append(f"Tag {x.key}: {x.value} not expected here. Nice try.")
message += f"Lookup({x.key}: {x.value}) "
if denied:
print("DENIED DICT", message)
message = [f"{i}" for i in message]
message = "\n".join(message)
#message = [f"{i}" for i in message]
#message = "\n".join(message)
message_class = "danger"
return {"message": message, "class": message_class}