From 0e4d93652b0d109b4f7e974810fc9e6b809742a9 Mon Sep 17 00:00:00 2001 From: Elijah Date: Wed, 6 Dec 2023 11:45:04 +0100 Subject: [PATCH] Added Data table --- idhub/admin/tables.py | 19 ++++++++++++++++++- idhub/admin/views.py | 7 +++++-- idhub/templates/idhub/admin/import.html | 2 ++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/idhub/admin/tables.py b/idhub/admin/tables.py index ec06042..ce19c48 100644 --- a/idhub/admin/tables.py +++ b/idhub/admin/tables.py @@ -1,7 +1,14 @@ import django_tables2 as tables from django.utils.html import format_html -from idhub.models import Rol, Event, Service, VerificableCredential, DID +from idhub.models import ( + Rol, + Event, + Service, + VerificableCredential, + DID, + File_datas +) from idhub_auth.models import User @@ -199,3 +206,13 @@ class DIDTable(tables.Table): model = DID template_name = "idhub/custom_table.html" fields = ("created_at", "label", "did", "edit_did", "delete_did") + + +class DataTable(tables.Table): + created_at = tables.Column(verbose_name="Date") + file_name = tables.Column(verbose_name="File") + + class Meta: + model = File_datas + template_name = "idhub/custom_table.html" + fields = ("created_at", "file_name", "success") diff --git a/idhub/admin/views.py b/idhub/admin/views.py index 1509433..d24eb6e 100644 --- a/idhub/admin/views.py +++ b/idhub/admin/views.py @@ -37,7 +37,8 @@ from idhub.admin.tables import ( RolesTable, ServicesTable, CredentialTable, - DIDTable + DIDTable, + DataTable ) from idhub.models import ( DID, @@ -867,10 +868,12 @@ class SchemasImportAddView(SchemasMix): return data -class ImportView(ImportExport, TemplateView): +class ImportView(ImportExport, SingleTableView): template_name = "idhub/admin/import.html" + table_class = DataTable subtitle = _('Import data') icon = '' + model = File_datas def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) diff --git a/idhub/templates/idhub/admin/import.html b/idhub/templates/idhub/admin/import.html index c0e3f64..6c280e4 100644 --- a/idhub/templates/idhub/admin/import.html +++ b/idhub/templates/idhub/admin/import.html @@ -1,5 +1,6 @@ {% extends "idhub/base_admin.html" %} {% load i18n %} +{% load render_table from django_tables2 %} {% block content %}

@@ -8,6 +9,7 @@

+ {% render_table table %}