Properly handle redactions

modern-tables
Mark Veidemanis 2 years ago
parent 2a3b1b82b3
commit b2c009080d
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

@ -104,15 +104,19 @@ def filter_blacklisted(user, response):
response["redacted"] += 1
# Anonymous
if user.is_anonymous:
response["hits"]["hits"].remove(item)
# Just set it to none so the index is not off
response["hits"]["hits"][index] = None
else:
if not user.is_superuser:
response["hits"]["hits"].remove(item)
response["hits"]["hits"][index] = None
else:
response["hits"]["hits"][index]["_source"][
"exemption"
] = True
# Actually get rid of all the things we set to None
response["hits"]["hits"] = [hit for hit in response["hits"]["hits"] if hit]
def run_main_query(client, user, query, custom_query=False, index=None, size=None):
"""

@ -10,22 +10,18 @@
<i class="fa-solid fa-chart-mixed"></i>
</div>
<div class="nowrap-child">
<p>{{ card }} hits</p>
</div>
{% if redacted != 0 %}
<div class="nowrap-child">
<p>{{ redacted }} redacted</p>
</div>
{% endif %}
<div class="nowrap-child">
<p>{{ took }}ms</p>
<p>fetched {{ results|length }} of {{ card }} hits in {{ took }}ms</p>
</div>
{% if exemption is not None %}
<div class="nowrap-child">
<i class="fa-solid fa-book-bible"></i>
</div>
{% else %}
{% if redacted != 0 %}
<div class="nowrap-child">
<p>{{ redacted }} redacted</p>
</div>
{% endif %}
{% endif %}
</div>
<div class="box">

Loading…
Cancel
Save