Fixed credential table, VerificableCredential description fix pending

This commit is contained in:
Elijah 2023-12-15 19:14:13 +01:00 committed by Elahi
parent c55db24954
commit 1ef91854a0
3 changed files with 16 additions and 37 deletions

View File

@ -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('<i class="bi bi-eye"></i>')
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"

View File

@ -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):

View File

@ -7,34 +7,5 @@
<i class="{{ icon }}"></i>
{{ subtitle }}
</h3>
<div class="row mt-5">
<div class="col">
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'Type' %}</button></th>
<th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'Details' %}</button></th>
<th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'Issued' %}</button></th>
<th scope="col" class="text-center"><button type="button" class="btn btn-grey border border-dark">{% trans 'Status' %}</button></th>
<th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'User' %}</button></th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
{% for f in credentials.all %}
<tr style="font-size:15px;">
<td>{{ f.type }}</td>
<td>{{ f.description }}</td>
<td>{{ f.get_issued_on }}</td>
<td class="text-center">{{ f.get_status }}</td>
<td>{{ f.user.email }}</td>
<td><a href="{% url 'idhub:admin_credential' f.id %}" class="text-primary" title="{% trans 'View' %}"><i class="bi bi-eye"></i></a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% render_table table %}
{% endblock %}