Skip to content
Snippets Groups Projects
Commit 48253bee authored by James Graham's avatar James Graham
Browse files

Add audit view to datasources and via organisational unit detail

parent c641b05e
No related branches found
No related tags found
No related merge requests found
{% extends "base.html" %}
{% load bootstrap4 %}
{% block content %}
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item" aria-current="page">
<a href="{% url 'index' %}">Home</a>
</li>
<li class="breadcrumb-item" aria-current="page">
<a href="{% url 'datasources:datasource.list' %}">Data Sources</a>
</li>
<li class="breadcrumb-item" aria-current="page">
<a href="{% url 'datasources:datasource.detail' pk=datasource.pk %}">{{ datasource.name }}</a>
</li>
<li class="breadcrumb-item active" aria-current="page">
Audit
</li>
</ol>
</nav>
<h2>Audit Data Source - {{ datasource.name }}</h2>
{% if datasource.description %}
<p>{{ datasource.description }}</p>
{% endif %}
<hr/>
<h4>Records</h4>
<table class="table">
<thead>
<tr>
<th scope="col"></th>
</tr>
</thead>
<tbody>
{% for record in records %}
<tr>
<td>{{ record.to_json }}</td>
</tr>
{% empty %}
<tr>
<td>No records</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
\ No newline at end of file
...@@ -13,6 +13,10 @@ urlpatterns = [ ...@@ -13,6 +13,10 @@ urlpatterns = [
views.datasource.DataSourceDetailView.as_view(), views.datasource.DataSourceDetailView.as_view(),
name='datasource.detail'), name='datasource.detail'),
path('<int:pk>/audit',
views.datasource.DataSourceAuditView.as_view(),
name='datasource.audit'),
path('<int:pk>/query', path('<int:pk>/query',
views.datasource.DataSourceQueryView.as_view(), views.datasource.DataSourceQueryView.as_view(),
name='datasource.query'), name='datasource.query'),
......
...@@ -6,6 +6,7 @@ import requests.exceptions ...@@ -6,6 +6,7 @@ import requests.exceptions
from datasources import models from datasources import models
from profiles.permissions import HasViewPermissionMixin from profiles.permissions import HasViewPermissionMixin
from provenance.models import ProvWrapper
class DataSourceListView(ListView): class DataSourceListView(ListView):
...@@ -111,3 +112,16 @@ class DataSourceExploreView(HasViewPermissionMixin, DetailView): ...@@ -111,3 +112,16 @@ class DataSourceExploreView(HasViewPermissionMixin, DetailView):
model = models.DataSource model = models.DataSource
template_name = 'datasources/datasource/explore.html' template_name = 'datasources/datasource/explore.html'
context_object_name = 'datasource' context_object_name = 'datasource'
class DataSourceAuditView(DetailView):
model = models.DataSource
template_name = 'datasources/datasource/audit.html'
context_object_name = 'datasource'
def get_context_data(self, **kwargs):
context = super().get_context_data()
context['records'] = ProvWrapper.filter_model_instance(self.object)
return context
...@@ -16,7 +16,15 @@ ...@@ -16,7 +16,15 @@
</ol> </ol>
</nav> </nav>
<h2>{{ organisational_unit.name }}</h2> <div class="row">
<div class="col-md-10 col-sm-8">
<h2>{{ organisational_unit.name }}</h2>
</div>
<div class="col-md-2 col-sm-4">
</div>
</div>
<h4 class="pt-3">Auditors</h4> <h4 class="pt-3">Auditors</h4>
...@@ -36,4 +44,26 @@ ...@@ -36,4 +44,26 @@
</tbody> </tbody>
</table> </table>
<h4 class="pt-3">Data Sources</h4>
<table class="table">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
{% for datasource in datasources %}
<tr>
<td>{{ datasource.name }}</td>
<td>
<a href="{% url 'datasources:datasource.audit' pk=datasource.pk %}"
class="btn btn-secondary" role="button">Audit</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<td>Organisational Unit</td> <td>Organisational Unit</td>
<td> <td>
{{ request.user.organisational_unit.name }} {{ request.user.organisational_unit.name }}
<a href="{% url 'profiles:organisational_unit.detail' pk=request.user.organisational_unit_id %}" <a href="{% url 'profiles:org_unit.detail' pk=request.user.organisational_unit_id %}"
class="btn btn-info">Detail</a> class="btn btn-info">Detail</a>
</td> </td>
</tr> </tr>
......
...@@ -21,5 +21,5 @@ urlpatterns = [ ...@@ -21,5 +21,5 @@ urlpatterns = [
path('orgunit/<int:pk>', path('orgunit/<int:pk>',
views.organisational_unit.OrganisationalUnitDetailView.as_view(), views.organisational_unit.OrganisationalUnitDetailView.as_view(),
name='organisational_unit.detail'), name='org_unit.detail'),
] ]
...@@ -7,3 +7,12 @@ class OrganisationalUnitDetailView(DetailView): ...@@ -7,3 +7,12 @@ class OrganisationalUnitDetailView(DetailView):
model = models.OrganisationalUnit model = models.OrganisationalUnit
template_name = 'profiles/organisational_unit/detail.html' template_name = 'profiles/organisational_unit/detail.html'
context_object_name = 'organisational_unit' context_object_name = 'organisational_unit'
def get_context_data(self, **kwargs):
context = super().get_context_data()
context['datasources'] = []
for user in self.object.users.all():
context['datasources'].extend(user.datasources.all())
return context
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment