diff --git a/idhub/admin/forms.py b/idhub/admin/forms.py new file mode 100644 index 0000000..cebefd8 --- /dev/null +++ b/idhub/admin/forms.py @@ -0,0 +1,5 @@ +from django import forms + + +class ImportForm(forms.Form): + file_import = forms.FileField() diff --git a/idhub/admin/views.py b/idhub/admin/views.py index e1c0fef..3e148d9 100644 --- a/idhub/admin/views.py +++ b/idhub/admin/views.py @@ -20,6 +20,7 @@ from apiregiter import iota from idhub_auth.models import User from idhub.mixins import AdminView from idhub.email.views import NotifyActivateUserByEmail +from idhub.admin.forms import ImportForm from idhub.models import ( DID, File_datas, @@ -28,7 +29,7 @@ from idhub.models import ( Service, Schemas, UserRol, - VerifiableCredential, + VerificableCredential, ) @@ -406,7 +407,7 @@ class AdminCredentialsView(Credentials): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context.update({ - 'credentials': VerifiableCredential.objects, + 'credentials': VerificableCredential.objects, }) return context @@ -763,7 +764,7 @@ class AdminImportStep3View(ImportExport): def create_credential(self, user, row): d = copy.copy(self.json_schema) d['instance'] = row - return VerifiableCredential.objects.create( + return VerificableCredential.objects.create( verified=False, user=user, data=json.dumps(d) diff --git a/idhub/migrations/0001_initial.py b/idhub/migrations/0001_initial.py index 26780eb..24b6c3c 100644 --- a/idhub/migrations/0001_initial.py +++ b/idhub/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.5 on 2023-10-26 13:46 +# Generated by Django 4.2.5 on 2023-10-27 09:32 from django.conf import settings from django.db import migrations, models @@ -96,7 +96,7 @@ class Migration(migrations.Migration): ], ), migrations.CreateModel( - name='VerifiableCredential', + name='VerificableCredential', fields=[ ( 'id', diff --git a/idhub/models.py b/idhub/models.py index f58f1a2..3b72f3f 100644 --- a/idhub/models.py +++ b/idhub/models.py @@ -48,7 +48,7 @@ class Schemas(models.Model): return self.get_schema.get('description', '') -class VerifiableCredential(models.Model): +class VerificableCredential(models.Model): """ Definition of Verificable Credentials """ @@ -90,6 +90,11 @@ class VerifiableCredential(models.Model): def get_status(self): return self.Status(self.status).label + def get_datas(self): + data = json.loads(self.data).get('instance').items() + return data + # import pdb; pdb.set_trace() + class VCTemplate(models.Model): wkit_template_id = models.CharField(max_length=250) data = models.TextField() diff --git a/idhub/templates/idhub/base.html b/idhub/templates/idhub/base.html index eca65be..29ccb1d 100644 --- a/idhub/templates/idhub/base.html +++ b/idhub/templates/idhub/base.html @@ -144,10 +144,6 @@ -
+ | + | + | + | + |
---|---|---|---|---|
{{ f.type }} | +{{ f.description }} | +{{ f.issue_on }} | +{{ f.get_status }} | ++ + + + | +