generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Filter database list by user access * Refactor filtering to a mixin and include Allow filtering of databases and tables by the users access * Super-linter * Disable HTML super linter * Only catch AttributeError in templatetags * Disable debug in prod * Bump chart version
- Loading branch information
1 parent
eeec73c
commit f50e1b0
Showing
10 changed files
with
136 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from django import template | ||
from django.urls import reverse | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.simple_tag | ||
def database_detail_url(database): | ||
try: | ||
return database.get_absolute_url() | ||
except AttributeError: | ||
return reverse("database_access:detail", kwargs={"database_name": database["Name"]}) | ||
|
||
|
||
@register.simple_tag | ||
def table_detail_url(table, database_name): | ||
try: | ||
return table.get_absolute_table_detail_url() | ||
except AttributeError: | ||
return reverse( | ||
"database_access:table_detail", | ||
kwargs={"database_name": database_name, "table_name": table["Name"]}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,38 @@ | ||
{% extends "base.html" %} | ||
{% load database_access_tags %} | ||
{% block title %}Analytical Platform - Tables for {{ database.name }}{% endblock title %} | ||
{% block content %} | ||
|
||
<span class="govuk-caption-xl">Database</span> | ||
<h1 class="govuk-heading-xl">{{ database.name }}</h1> | ||
<div class="govuk-width-container"> | ||
|
||
{% if database.tables %} | ||
<table class="govuk-table"> | ||
<thead class="govuk-table__head"> | ||
<tr class="govuk-table__row"> | ||
<th scope="col" class="govuk-table__header">Table Name</th> | ||
<th scope="col" class="govuk-table__header">Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody class="govuk-table__body"> | ||
{% for table in database.tables %} | ||
<span class="govuk-caption-xl">Database</span> | ||
<h1 class="govuk-heading-xl">{{ database_name }}</h1> | ||
|
||
{% include "database_access/database/includes/filter_form.html" %} | ||
|
||
{% if tables %} | ||
<table class="govuk-table"> | ||
<thead class="govuk-table__head"> | ||
<tr class="govuk-table__row"> | ||
<td class="govuk-table__cell">{{ table.Name }}</td> | ||
<td class="govuk-table__cell"> | ||
<a href="{% url 'database_access:table_detail' database.name table.Name %}" class="govuk-link">View</a> | ||
</td> | ||
<th scope="col" class="govuk-table__header">Table Name</th> | ||
<th scope="col" class="govuk-table__header">Actions</th> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% else %} | ||
<p class="govuk-body">No tables found.</p> | ||
{% endif %} | ||
</thead> | ||
<tbody class="govuk-table__body"> | ||
{% for table in tables %} | ||
<tr class="govuk-table__row"> | ||
<td class="govuk-table__cell">{% firstof table.name table.Name %}</td> | ||
<td class="govuk-table__cell"> | ||
<a href="{% table_detail_url table=table database_name=database_name %}" class="govuk-link">View</a> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% else %} | ||
<p class="govuk-body">No tables found.</p> | ||
{% endif %} | ||
|
||
</div> | ||
|
||
{% endblock %} |
11 changes: 11 additions & 0 deletions
11
templates/database_access/database/includes/filter_form.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<div class="govuk-form-group"> | ||
<form id="filter-form"> | ||
<label class="govuk-label" for="filter"> | ||
Filter by | ||
</label> | ||
<select class="govuk-select" id="filter" name="filter" onchange="document.getElementById('filter-form').submit();"> | ||
<option value="all" {% if "all" in request.GET.filter %}selected{% endif %}>All</option> | ||
<option value="my-access" {% if "my-access" in request.GET.filter %}selected{% endif %}>My access</option> | ||
</select> | ||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters