From 1ef91854a0aeeb8edf9347124b9e3fa25a26038d Mon Sep 17 00:00:00 2001 From: Elijah Date: Fri, 15 Dec 2023 19:14:13 +0100 Subject: [PATCH] Fixed credential table, VerificableCredential description fix pending --- idhub/admin/tables.py | 10 ++++++- idhub/admin/views.py | 12 ++++---- idhub/templates/idhub/admin/credentials.html | 31 +------------------- 3 files changed, 16 insertions(+), 37 deletions(-) diff --git a/idhub/admin/tables.py b/idhub/admin/tables.py index a95ad63..6fa3c86 100644 --- a/idhub/admin/tables.py +++ b/idhub/admin/tables.py @@ -154,7 +154,8 @@ class DashboardTable(tables.Table): class CredentialTable(tables.Table): type = tables.Column(empty_values=()) - details = tables.Column(empty_values=()) + # Pending VerificableCredential description fix + details = tables.Column(empty_values=(), orderable=False) issued_on = tables.Column(verbose_name="Issued") view_credential = ButtonColumn( linkify={ @@ -173,6 +174,13 @@ class CredentialTable(tables.Table): def render_view_credential(self): return format_html('') + def order_type(self, queryset, is_descending): + queryset = queryset.order_by( + ("-" if is_descending else "") + "schema__type" + ) + + return (queryset, True) + class Meta: model = VerificableCredential template_name = "idhub/custom_table.html" diff --git a/idhub/admin/views.py b/idhub/admin/views.py index 255f5ab..d0b9405 100644 --- a/idhub/admin/views.py +++ b/idhub/admin/views.py @@ -554,7 +554,7 @@ class ServiceDeleteView(AccessControl): return redirect('idhub:admin_services') -class CredentialsView(Credentials): +class CredentialsView(Credentials, SingleTableView): template_name = "idhub/admin/credentials.html" table_class = CredentialTable subtitle = _('View credentials') @@ -562,11 +562,11 @@ class CredentialsView(Credentials): model = VerificableCredential def get_context_data(self, **kwargs): - context = super().get_context_data(**kwargs) - context.update({ - 'credentials': VerificableCredential.objects, - }) - return context + queryset = kwargs.pop('object_list', None) + if queryset is None: + self.object_list = self.model.objects.all() + + return super().get_context_data(**kwargs) class CredentialView(Credentials): diff --git a/idhub/templates/idhub/admin/credentials.html b/idhub/templates/idhub/admin/credentials.html index 43dc413..4862f82 100644 --- a/idhub/templates/idhub/admin/credentials.html +++ b/idhub/templates/idhub/admin/credentials.html @@ -7,34 +7,5 @@ {{ subtitle }} -
-
-
- - - - - - - - - - - - - {% for f in credentials.all %} - - - - - - - - - {% endfor %} - -
{{ f.type }}{{ f.description }}{{ f.get_issued_on }}{{ f.get_status }}{{ f.user.email }}
-
-
-
+{% render_table table %} {% endblock %}