Skip to content

Commit

Permalink
fixup! Permissions as HTML page
Browse files Browse the repository at this point in the history
  • Loading branch information
mvalik committed Oct 11, 2023
1 parent 739b2d2 commit 5f79273
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
12 changes: 12 additions & 0 deletions tests/test_api_v10.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"<td>{config['PERMISSIONS'][0]['name']}</td>" in r.text
assert f"<td>{config['PERMISSIONS'][1]['name']}</td>" 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"<td>{config['PERMISSIONS'][0]['name']}</td>" not in r.text
assert f"<td>{config['PERMISSIONS'][1]['name']}</td>" in r.text


def test_config_endpoint_superusers(client):
config = {
Expand Down
21 changes: 15 additions & 6 deletions waiverdb/templates/permissions.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,28 @@ <h1>
<th>Description</th>
<th>Maintainers</th>
<th>Testcases</th>
<th>User groups</th>
<th>Users/Groups</th>
</tr>
</thead>
<tbody>
{% for p in permissions %}
{% for p in permissions -%}
<tr>
<td>{{ p["name"] }}</td>
<td>{{ p["description"] }}</td>
<td>{{ p["maintainers"] | map("urlize") | join("<br />") | safe }}</td>
<td>{{ p["testcases"] | join("<br />") | safe }}</td>
<td>{{ p["groups"] | join("<br />") | safe }}</td>
<td>{{ p["maintainers"] | map("urlize") | safe | join("<br />") | safe }}</td>
<td>{{ p["testcases"] | map("replace('-', '&#8209;')") | join("<br />") | safe }}</td>
<td>
{% if p["groups"] | length > 0 -%}
<span class="font-weight-bold">Groups:</span><br />
{{ p["groups"] | map("replace('-', '&#8209;')") | join("<br />") | safe }}
{%- endif %}
{% if p["users"] | length > 0 -%}
<span class="font-weight-bold">Users:</span><br />
{{ p["users"] | map("replace('-', '&#8209;')") | join("<br />") | safe }}
{%- endif %}
</td>
</tr>
{% endfor %}
{%- endfor %}
</tbody>
</table>
</div>
Expand Down

0 comments on commit 5f79273

Please sign in to comment.