filter_dict and new template membership
This commit is contained in:
parent
f54a6f9729
commit
16ea7631dc
|
@ -1,6 +1,8 @@
|
|||
import json
|
||||
import ujson
|
||||
import pytz
|
||||
import datetime
|
||||
from collections import OrderedDict
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from django.template.loader import get_template
|
||||
|
@ -525,10 +527,13 @@ class VerificableCredential(models.Model):
|
|||
self.status = self.Status.ISSUED
|
||||
self.subject_did = did
|
||||
self.issued_on = datetime.datetime.now().astimezone(pytz.utc)
|
||||
self.data = sign_credential(
|
||||
data = sign_credential(
|
||||
self.render(),
|
||||
self.issuer_did.key_material
|
||||
)
|
||||
d_ordered = ujson.loads(data)
|
||||
d_minimum = self.filter_dict(d_ordered)
|
||||
self.data = ujson.dumps(d_minimum)
|
||||
|
||||
def get_context(self):
|
||||
d = json.loads(self.csv_data)
|
||||
|
@ -544,6 +549,7 @@ class VerificableCredential(models.Model):
|
|||
'issuance_date': issuance_date,
|
||||
'first_name': self.user.first_name,
|
||||
'last_name': self.user.last_name,
|
||||
'email': self.user.email
|
||||
}
|
||||
context.update(d)
|
||||
return context
|
||||
|
@ -564,7 +570,7 @@ class VerificableCredential(models.Model):
|
|||
return ''
|
||||
|
||||
def filter_dict(self, dic):
|
||||
new_dict = {}
|
||||
new_dict = OrderedDict()
|
||||
for key, value in dic.items():
|
||||
if isinstance(value, dict):
|
||||
new_value = self.filter_dict(value)
|
||||
|
|
|
@ -1,67 +1,67 @@
|
|||
{
|
||||
"@context": [
|
||||
"https://www.w3.org/2018/credentials/v1",
|
||||
"https://idhub.pangea.org/credentials/base/v1",
|
||||
"https://idhub.pangea.org/credentials/membership-card/v1"
|
||||
],
|
||||
"type": [
|
||||
"VerifiableCredential",
|
||||
"VerifiableAttestation",
|
||||
"MembershipCard"
|
||||
],
|
||||
"id": "https://idhub.pangea.org/credentials/987654321",
|
||||
"issuer": {
|
||||
"id": "did:example:5678",
|
||||
"name": "Pangea Internet Solidari"
|
||||
"@context": [
|
||||
"https://www.w3.org/2018/credentials/v1",
|
||||
"https://idhub.pangea.org/credentials/base/v1",
|
||||
"https://idhub.pangea.org/credentials/membership-card/v1"
|
||||
],
|
||||
"type": [
|
||||
"VerifiableCredential",
|
||||
"VerifiableAttestation",
|
||||
"MembershipCard"
|
||||
],
|
||||
"id": "[[PLACEHOLDER]]",
|
||||
"issuer": {
|
||||
"id": "[[PLACEHOLDER]]",
|
||||
"name": "[[PLACEHOLDER]]"
|
||||
},
|
||||
"issuanceDate": "[[PLACEHOLDER]]",
|
||||
"issued": "[[PLACEHOLDER]]",
|
||||
"validFrom": "[[PLACEHOLDER]]",
|
||||
"validUntil": "[[PLACEHOLDER]]",
|
||||
"name": [
|
||||
{
|
||||
"value": "Membership Card",
|
||||
"lang": "en"
|
||||
},
|
||||
"issuanceDate": "2023-12-06T19:23:24Z",
|
||||
"issued": "2023-12-06T19:23:24Z",
|
||||
"validFrom": "2023-12-06T19:23:24Z",
|
||||
"validUntil": "2024-12-06T19:23:24Z",
|
||||
"name": [
|
||||
{
|
||||
"value": "Membership Card",
|
||||
"lang": "en"
|
||||
},
|
||||
{
|
||||
"value": "Carnet de soci/a",
|
||||
"lang": "ca_ES"
|
||||
},
|
||||
{
|
||||
"value": "Carnet de socio/a",
|
||||
"lang": "es"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"value": "The membership card specifies an individual's subscription or enrollment in specific services or benefits issued by an organization.",
|
||||
"lang": "en"
|
||||
},
|
||||
{
|
||||
"value": "El carnet de soci especifica la subscripció o la inscripció d'un individu en serveis o beneficis específics emesos per una organització.",
|
||||
"lang": "ca_ES"
|
||||
},
|
||||
{
|
||||
"value": "El carnet de socio especifica la suscripción o inscripción de un individuo en servicios o beneficios específicos emitidos por uns organización.",
|
||||
"lang": "es"
|
||||
}
|
||||
],
|
||||
"credentialSubject": {
|
||||
"id": "did:example:1234",
|
||||
"firstName": "Joan",
|
||||
"lastName": "Pera",
|
||||
"email": "joan.pera@pangea.org",
|
||||
"typeOfPerson": "natural",
|
||||
"identityDocType": "DNI",
|
||||
"identityNumber": "12345678A",
|
||||
"organisation": "Pangea",
|
||||
"membershipType": "individual",
|
||||
"membershipId": "123456",
|
||||
"affiliatedSince": "2023-01-01T00:00:00Z",
|
||||
"affiliatedUntil": "2024-01-01T00:00:00Z"
|
||||
{
|
||||
"value": "Carnet de soci/a",
|
||||
"lang": "ca_ES"
|
||||
},
|
||||
"credentialSchema": {
|
||||
"id": "https://idhub.pangea.org/vc_schemas/membership-card.json",
|
||||
"type": "FullJsonSchemaValidator2021"
|
||||
{
|
||||
"value": "Carnet de socio/a",
|
||||
"lang": "es"
|
||||
}
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"value": "The membership card specifies an individual's subscription or enrollment in specific services or benefits issued by an organization.",
|
||||
"lang": "en"
|
||||
},
|
||||
{
|
||||
"value": "El carnet de soci especifica la subscripció o la inscripció d'un individu en serveis o beneficis específics emesos per una organització.",
|
||||
"lang": "ca_ES"
|
||||
},
|
||||
{
|
||||
"value": "El carnet de socio especifica la suscripción o inscripción de un individuo en servicios o beneficios específicos emitidos por uns organización.",
|
||||
"lang": "es"
|
||||
}
|
||||
],
|
||||
"credentialSubject": {
|
||||
"id": "[[PLACEHOLDER]]",
|
||||
"firstName": "[[PLACEHOLDER]]",
|
||||
"lastName": "[[PLACEHOLDER]]",
|
||||
"email": "[[PLACEHOLDER]]",
|
||||
"typeOfPerson": "[[PLACEHOLDER]]",
|
||||
"identityDocType": "[[PLACEHOLDER]]",
|
||||
"identityNumber": "[[PLACEHOLDER]]",
|
||||
"organisation": "[[PLACEHOLDER]]",
|
||||
"membershipType": "[[PLACEHOLDER]]",
|
||||
"membershipId": "[[PLACEHOLDER]]",
|
||||
"affiliatedSince": "[[PLACEHOLDER]]",
|
||||
"affiliatedUntil": "[[PLACEHOLDER]]"
|
||||
},
|
||||
"credentialSchema": {
|
||||
"id": "https://idhub.pangea.org/vc_schemas/membership-card.json",
|
||||
"type": "FullJsonSchemaValidator2021"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue