Fix restricted source handling

This commit is contained in:
Mark Veidemanis 2022-08-26 07:20:30 +01:00
parent f14110dcd9
commit c597af5523
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 4 additions and 4 deletions

View File

@ -347,7 +347,7 @@ def query_results(
source = query_params["source"] source = query_params["source"]
if source in settings.OPENSEARCH_SOURCES_RESTRICTED: if source in settings.OPENSEARCH_SOURCES_RESTRICTED:
if not request.user.has_perm("restricted_sources"): if not request.user.has_perm("core.restricted_sources"):
message = "Access denied" message = "Access denied"
message_class = "danger" message_class = "danger"
return {"message": message, "class": message_class} return {"message": message, "class": message_class}
@ -363,11 +363,11 @@ def query_results(
sources = [source] sources = [source]
else: else:
sources = settings.OPENSEARCH_MAIN_SOURCES sources = settings.OPENSEARCH_MAIN_SOURCES
if request.user.has_perm("restricted_sources"): print("SOURCES", sources)
if request.user.has_perm("core.restricted_sources"):
print("HAS PERM")
for source_iter in settings.OPENSEARCH_SOURCES_RESTRICTED: for source_iter in settings.OPENSEARCH_SOURCES_RESTRICTED:
sources.append(source_iter) sources.append(source_iter)
else:
sources = settings.OPENSEARCH_MAIN_SOURCES
add_top_tmp = {"bool": {"should": []}} add_top_tmp = {"bool": {"should": []}}
for source_iter in sources: for source_iter in sources: