add admin credentials view

This commit is contained in:
Cayo Puigdefabregas 2023-10-31 10:59:19 +01:00
parent 2ca1663e90
commit 028770a52c
4 changed files with 74 additions and 9 deletions

View File

@ -412,10 +412,23 @@ class AdminCredentialsView(Credentials):
return context
class AdminIssueCredentialsView(Credentials):
class AdminCredentialView(Credentials):
template_name = "idhub/admin/issue_credentials.html"
subtitle = _('Issuance of Credentials')
subtitle = _('Change status of Credential')
icon = ''
model = VerificableCredential
def get(self, request, *args, **kwargs):
self.pk = kwargs['pk']
self.object = get_object_or_404(self.model, pk=self.pk)
return super().get(request, *args, **kwargs)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update({
'object': self.object,
})
return context
class AdminRevokeCredentialsView(Credentials):

View File

@ -28,7 +28,7 @@
<td>{{ f.issue_on }}</td>
<td>{{ f.get_status }}</td>
<td>{{ f.user.email }}</td>
<td><button type="button" class="btn btn-green-admin">{% trans 'View' %}</button></td>
<td><a href="{% url 'idhub:admin_credential' f.id %}" class="btn btn-green-admin">{% trans 'View' %}</a></td>
</tr>
{% endfor %}
</tbody>

View File

@ -2,8 +2,60 @@
{% load i18n %}
{% block content %}
<h3>
<i class="{{ icon }}"></i>
{{ subtitle }}
</h3>
<div class="row">
<div class="col">
<h3>
<i class="{{ icon }}"></i>
{{ subtitle }}
</h3>
</div>
<div class="col text-end">
{% if object.get_status == 'Issued' %}
<a class="btn btn-yellow" href="{% url 'idhub:user_credential_json' object.id %}">{% trans 'Revoke' %}</a>
<a class="btn btn-orange" href="{% url 'idhub:user_credential_json' object.id %}">{% trans 'Delete' %}</a>
{% elif object.get_status == 'Required' %}
<a class="btn btn-yellow" href="{% url 'idhub:user_credential_json' object.id %}">{% trans 'Accept' %}</a>
<a class="btn btn-orange" href="{% url 'idhub:user_credential_json' object.id %}">{% trans 'Deny' %}</a>
{% elif object.get_status == 'Issued' %}
<a class="btn btn-yellow" href="{% url 'idhub:user_credential_json' object.id %}">{% trans 'Revoke' %}</a>
{% endif %}
</div>
</div>
<div class="row">
<div class="col-3">
</div>
<div class="col">
{% for k, v in object.get_datas %}
<div class="row mt-3">
<div class="col-3 text-end">
<strong>{{ k|capfirst }}:</strong>
</div>
<div class="col bg-light text-secondary">
{{ v }}
</div>
</div>
{% endfor %}
<div class="row mt-3">
<div class="col-3 text-end">
<strong>Date of Issue:</strong>
</div>
<div class="col bg-light text-secondary">
{{ object.issuer_on|default_if_none:"" }}
</div>
</div>
<div class="row mt-3">
<div class="col-3 text-end">
<strong>Status:</strong>
</div>
<div class="col bg-light text-secondary">
{{ object.get_status}}
</div>
</div>
<div class="row mt-3">
<div class="col text-center">
<a class="btn btn-green-user" href="{% url 'idhub:user_credential_json' object.id %}">{% trans 'View in JSON format' %}</a>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -136,8 +136,8 @@ urlpatterns = [
name='admin_service_del'),
path('admin/credentials/', views_admin.AdminCredentialsView.as_view(),
name='admin_credentials'),
path('admin/credentials/new/', views_admin.AdminIssueCredentialsView.as_view(),
name='admin_credentials_new'),
path('admin/credentials/<int:pk>/', views_admin.AdminCredentialView.as_view(),
name='admin_credential'),
path('admin/credentials/revoke/', views_admin.AdminRevokeCredentialsView.as_view(),
name='admin_credentials_revoke'),
path('admin/wallet/identities/', views_admin.AdminDidsView.as_view(),