From 9a16d71a63a5e3846c6da0115fa24f445ea6f296 Mon Sep 17 00:00:00 2001 From: Carlos Vega <carlos.vega@uni.lu> Date: Thu, 19 Mar 2020 17:21:25 +0100 Subject: [PATCH] add view and template for provenance --- .../web/templates/provenance/breadcrumb.html | 2 + smash/web/templates/provenance/list.html | 70 +++++++++++++++++++ smash/web/views/provenance.py | 15 ++++ 3 files changed, 87 insertions(+) create mode 100644 smash/web/templates/provenance/breadcrumb.html create mode 100644 smash/web/templates/provenance/list.html create mode 100644 smash/web/views/provenance.py diff --git a/smash/web/templates/provenance/breadcrumb.html b/smash/web/templates/provenance/breadcrumb.html new file mode 100644 index 00000000..1d4019a6 --- /dev/null +++ b/smash/web/templates/provenance/breadcrumb.html @@ -0,0 +1,2 @@ +<li><a href="{% url 'web.views.provenance' %}"><i class="fa fa-dashboard"></i> Dashboard</a></li> +<li class="active"><a href="{% url 'web.views.provenance' %}">Provenance</a></li> \ No newline at end of file diff --git a/smash/web/templates/provenance/list.html b/smash/web/templates/provenance/list.html new file mode 100644 index 00000000..42840c32 --- /dev/null +++ b/smash/web/templates/provenance/list.html @@ -0,0 +1,70 @@ +{% extends "_base.html" %} +{% load static %} + +{% block styles %} + {{ block.super }} + <!-- DataTables --> + <link rel="stylesheet" href="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.css' %}"> +{% endblock styles %} + +{% block ui_active_tab %}'provenance'{% endblock ui_active_tab %} +{% block page_header %}Provenance{% endblock page_header %} +{% block page_description %}{% endblock page_description %} + +{% block breadcrumb %} + {% include "languages/breadcrumb.html" %} +{% endblock breadcrumb %} + +{% block maincontent %} + + <div class="box-body"> + <table id="table" class="table table-bordered table-striped"> + <thead> + <tr> + <th>Table</th> + <th>Row</th> + <th>Date</th> + <th>Author</th> + <th>Field</th> + <th>Previous Value</th> + <th>New Value</th> + <th>Description</th> + </tr> + </thead> + <tbody> + {% for provenance in provenances %} + <tr> + <td>{{ provenance.modified_table }}</td> + <td>{{ provenance.modified_table_id }}</td> + <td>{{ provenance.modification_date }}</td> + <td>{{ provenance.modification_author }}</td> + <td>{{ provenance.modified_field }}</td> + <td>{{ provenance.previous_value }}</td> + <td>{{ provenance.new_value }}</td> + <td>{{ provenance.modification_description }}</td> + </tr> + {% endfor %} + </tbody> + </table> + </div> +{% endblock maincontent %} + +{% block scripts %} + {{ block.super }} + + <script src="{% static 'AdminLTE/plugins/datatables/jquery.dataTables.min.js' %}"></script> + <script src="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.min.js' %}"></script> + + <script> + $(function () { + $('#table').DataTable({ + "paging": true, + "lengthChange": false, + "searching": true, + "ordering": true, + "info": true, + "autoWidth": false + }); + }); + </script> +{% endblock scripts %} diff --git a/smash/web/views/provenance.py b/smash/web/views/provenance.py new file mode 100644 index 00000000..dc2e8529 --- /dev/null +++ b/smash/web/views/provenance.py @@ -0,0 +1,15 @@ +# coding=utf-8 +from django.views.generic import ListView + +from . import WrappedView +from ..models import Provenance +from web.decorators import PermissionDecorator + +class ProvenanceListView(ListView, WrappedView): + model = Provenance + context_object_name = "provenances" + template_name = 'provenance/list.html' + + @PermissionDecorator('view_provenance', 'configuration') + def dispatch(self, *args, **kwargs): + return super(ProvenanceListView, self).dispatch(*args, **kwargs) \ No newline at end of file -- GitLab