diff --git a/datasources/templates/datasources/datasource/audit.html b/datasources/templates/datasources/datasource/audit.html new file mode 100644 index 0000000000000000000000000000000000000000..ca0348fc187803f6f3b1a39a9c1ed4f6382bee0b --- /dev/null +++ b/datasources/templates/datasources/datasource/audit.html @@ -0,0 +1,51 @@ +{% 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 diff --git a/datasources/urls.py b/datasources/urls.py index cdba90c399196596ad1e8384d54529d2484585a2..23584dc603fa409615369bc04556dd2f0b7e052b 100644 --- a/datasources/urls.py +++ b/datasources/urls.py @@ -13,6 +13,10 @@ urlpatterns = [ views.datasource.DataSourceDetailView.as_view(), name='datasource.detail'), + path('<int:pk>/audit', + views.datasource.DataSourceAuditView.as_view(), + name='datasource.audit'), + path('<int:pk>/query', views.datasource.DataSourceQueryView.as_view(), name='datasource.query'), diff --git a/datasources/views/datasource.py b/datasources/views/datasource.py index fc2f6ccf802075eb05b6f947a4f2c95a6c10586c..c5e18b03aa1e0b34deb40a0a01d2790ebec35912 100644 --- a/datasources/views/datasource.py +++ b/datasources/views/datasource.py @@ -6,6 +6,7 @@ import requests.exceptions from datasources import models from profiles.permissions import HasViewPermissionMixin +from provenance.models import ProvWrapper class DataSourceListView(ListView): @@ -111,3 +112,16 @@ class DataSourceExploreView(HasViewPermissionMixin, DetailView): model = models.DataSource template_name = 'datasources/datasource/explore.html' 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 diff --git a/profiles/templates/profiles/organisational_unit/detail.html b/profiles/templates/profiles/organisational_unit/detail.html index be5c251c5cdaafd31bf80bcfbd1027338a4b39a1..22e75d418cc817fa96a2506d789773895fd8cc01 100644 --- a/profiles/templates/profiles/organisational_unit/detail.html +++ b/profiles/templates/profiles/organisational_unit/detail.html @@ -16,7 +16,15 @@ </ol> </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> @@ -36,4 +44,26 @@ </tbody> </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 %} \ No newline at end of file diff --git a/profiles/templates/profiles/user/profile.html b/profiles/templates/profiles/user/profile.html index 7ff10e83ef7168d58f4f7ac386d2de62bab3f6c2..91786dd7d77c499acd61bd0fbc9ec60d488fe1c4 100644 --- a/profiles/templates/profiles/user/profile.html +++ b/profiles/templates/profiles/user/profile.html @@ -27,7 +27,7 @@ <td>Organisational Unit</td> <td> {{ 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> </td> </tr> diff --git a/profiles/urls.py b/profiles/urls.py index c55df55822158162948e4172b874fa355c83fb1a..4e3c29ea6bb99faf1afed91882b5f8ccb4db35fd 100644 --- a/profiles/urls.py +++ b/profiles/urls.py @@ -21,5 +21,5 @@ urlpatterns = [ path('orgunit/<int:pk>', views.organisational_unit.OrganisationalUnitDetailView.as_view(), - name='organisational_unit.detail'), + name='org_unit.detail'), ] diff --git a/profiles/views/organisational_unit.py b/profiles/views/organisational_unit.py index fa42b513f99cf4fce3b4d202f9fa225aef36facc..c5f8b6630a4f8bc267e0c642c375d563c08c84d1 100644 --- a/profiles/views/organisational_unit.py +++ b/profiles/views/organisational_unit.py @@ -7,3 +7,12 @@ class OrganisationalUnitDetailView(DetailView): model = models.OrganisationalUnit template_name = 'profiles/organisational_unit/detail.html' 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