From 488c00c37866702efca6266c66eff45f19c609e7 Mon Sep 17 00:00:00 2001 From: Valerij Maljulin Date: Wed, 11 Oct 2023 11:35:23 +0200 Subject: [PATCH] fixup! Permissions as HTML page --- tests/test_api_v10.py | 12 ++++++++++++ waiverdb/templates/permissions.html | 23 ++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/tests/test_api_v10.py b/tests/test_api_v10.py index 0e1445c0..766815ed 100644 --- a/tests/test_api_v10.py +++ b/tests/test_api_v10.py @@ -892,6 +892,18 @@ def test_permissions_endpoint(client): assert r.status_code == 200 assert r.json == config['PERMISSIONS'][0:1] + r = client.get('/api/v1.0/permissions?html=1') + assert r.status_code == 200 + assert r.content_type == 'text/html' + assert f"{config['PERMISSIONS'][0]['name']}" in r.text + assert f"{config['PERMISSIONS'][1]['name']}" in r.text + + r = client.get('/api/v1.0/permissions?testcase=greenwave-tests.test1&html=1') + assert r.status_code == 200 + assert r.content_type == 'text/html' + assert f"{config['PERMISSIONS'][0]['name']}" not in r.text + assert f"{config['PERMISSIONS'][1]['name']}" in r.text + def test_config_endpoint_superusers(client): config = { diff --git a/waiverdb/templates/permissions.html b/waiverdb/templates/permissions.html index f43201c0..b8c1c068 100644 --- a/waiverdb/templates/permissions.html +++ b/waiverdb/templates/permissions.html @@ -25,26 +25,35 @@

Waiver DB {{ self.title() }}

- +
- + - {% for p in permissions %} + {% for p in permissions -%} - - - + + + - {% endfor %} + {%- endfor %}
Name Description Maintainers TestcasesUser groupsUsers/Groups
{{ p["name"] }} {{ p["description"] }}{{ p["maintainers"] | map("urlize") | join("
") | safe }}
{{ p["testcases"] | join("
") | safe }}
{{ p["groups"] | join("
") | safe }}
{{ p["maintainers"] | map("urlize") | safe | join("
") | safe }}
{{ p["testcases"] | map("replace('-', '‑')") | join("
") | safe }}
+ {% if p["groups"] | length > 0 -%} + Groups:
+ {{ p["groups"] | map("replace('-', '‑')") | join("
") | safe }} + {%- endif %} + {% if p["users"] | length > 0 -%} + Users:
+ {{ p["users"] | map("replace('-', '‑')") | join("
") | safe }} + {%- endif %} +