diff --git a/idhub/models.py b/idhub/models.py
index 3b72f3f..037bd12 100644
--- a/idhub/models.py
+++ b/idhub/models.py
@@ -54,9 +54,10 @@ class VerificableCredential(models.Model):
"""
class Status(models.IntegerChoices):
ENABLE = 1, _("Enable")
- ISSUED = 2, _("Issued")
- REVOKED = 3, _("Revoked")
- EXPIRED = 4, _("Expired")
+ REQUIRED = 2, _("Required")
+ ISSUED = 3, _("Issued")
+ REVOKED = 4, _("Revoked")
+ EXPIRED = 5, _("Expired")
id_string = models.CharField(max_length=250)
verified = models.BooleanField()
diff --git a/idhub/templates/idhub/base.html b/idhub/templates/idhub/base.html
index 29ccb1d..f279027 100644
--- a/idhub/templates/idhub/base.html
+++ b/idhub/templates/idhub/base.html
@@ -110,8 +110,8 @@
-
- Credentials required
+
+ Credentials request
diff --git a/idhub/templates/idhub/user/credentials_request.html b/idhub/templates/idhub/user/credentials_request.html
new file mode 100644
index 0000000..a2bf5bb
--- /dev/null
+++ b/idhub/templates/idhub/user/credentials_request.html
@@ -0,0 +1,39 @@
+{% extends "idhub/base.html" %}
+{% load i18n %}
+
+{% block content %}
+
+
+ {{ subtitle }}
+
+
+
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+ {% for f in credentials.all %}
+
+ {{ f.type }} |
+ {{ f.description }} |
+ {{ f.created_on }} |
+
+
+ {% trans 'Request' %}
+
+ |
+
+ {% endfor %}
+
+
+
+
+
+{% endblock %}
diff --git a/idhub/templates/idhub/user/credentials_required.html b/idhub/templates/idhub/user/credentials_required.html
deleted file mode 100644
index 1ac25fd..0000000
--- a/idhub/templates/idhub/user/credentials_required.html
+++ /dev/null
@@ -1,9 +0,0 @@
-{% extends "idhub/base.html" %}
-{% load i18n %}
-
-{% block content %}
-
-
- {{ subtitle }}
-
-{% endblock %}
diff --git a/idhub/urls.py b/idhub/urls.py
index d38cd6f..6f13025 100644
--- a/idhub/urls.py
+++ b/idhub/urls.py
@@ -81,9 +81,12 @@ urlpatterns = [
name='user_credential'),
path('user/credentials//json', views_user.UserCredentialJsonView.as_view(),
name='user_credential_json'),
- path('user/credentials_required/',
- views_user.UserCredentialsRequiredView.as_view(),
- name='user_credentials_required'),
+ path('user/credentials/request/',
+ views_user.UserCredentialsRequestView.as_view(),
+ name='user_credentials_request'),
+ path('user/credentials//request/',
+ views_user.UserCredentialRequestView.as_view(),
+ name='user_credential_request'),
path('user/credentials_presentation/',
views_user.UserCredentialsPresentationView.as_view(),
name='user_credentials_presentation'),
diff --git a/idhub/user/views.py b/idhub/user/views.py
index 7a992b7..444256b 100644
--- a/idhub/user/views.py
+++ b/idhub/user/views.py
@@ -104,19 +104,43 @@ class UserCredentialJsonView(MyWallet, TemplateView):
return response
-class UserCredentialsRequiredView(MyWallet, TemplateView):
- template_name = "idhub/user/credentials_required.html"
- subtitle = _('Credentials required')
+class UserCredentialsRequestView(MyWallet, TemplateView):
+ template_name = "idhub/user/credentials_request.html"
+ subtitle = _('Credentials request')
icon = 'bi bi-patch-check-fill'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
+ creds = VerificableCredential.objects.filter(
+ user=self.request.user,
+ status=VerificableCredential.Status.ENABLE
+ )
context.update({
- 'credentials': VerificableCredential.objects,
+ 'credentials': creds,
})
return context
+class UserCredentialRequestView(MyWallet, TemplateView):
+ success_url = reverse_lazy('idhub:user_credentials_request')
+
+ def get(self, request, *args, **kwargs):
+ pk = kwargs['pk']
+ creds = VerificableCredential.objects.filter(
+ pk=pk,
+ user=self.request.user,
+ status=VerificableCredential.Status.ENABLE
+ )
+ if not creds:
+ messages.error(self.request, _("Not exists the credential!"))
+ else:
+ cred = creds[0]
+ cred.status = VerificableCredential.Status.REQUIRED
+ cred.save()
+ messages.success(self.request, _("The credential was required successfully!"))
+ return redirect(self.success_url)
+
+
class UserCredentialsPresentationView(MyWallet, TemplateView):
template_name = "idhub/user/credentials_presentation.html"
subtitle = _('Credentials Presentation')