DPP/DLT functionality #36

Merged
pedro merged 68 commits from dpp into main 2024-12-11 15:15:14 +00:00
Showing only changes of commit 13249d564f - Show all commits

View file

@ -1,11 +1,13 @@
import json
import logging
from django.views.generic.edit import View
from django.http import JsonResponse
from evidence.xapian import search
from dpp.models import Proof
from dpp.api_dlt import ALGORITHM
from evidence.models import Evidence
from evidence.parse import Build
from dpp.models import Proof
logger = logging.getLogger('django')
@ -21,26 +23,22 @@ class ProofView(View):
if not proof:
return JsonResponse({}, status=404)
ev_uuid = 'uuid:"{}"'.format(proof.uuid)
matches = search(None, ev_uuid, limit=1)
if not matches or matches.size() < 1:
ev = Evidence(proof.uuid)
if not ev.doc:
return JsonResponse({}, status=404)
for x in matches:
snap = x.document.get_data()
dev = Build(ev.doc, None, check=True)
doc = dev.get_phid()
data = {
"algorithm": ALGORITHM,
"document": snap
}
d = {
'@context': ['https://ereuse.org/proof0.json'],
'data': data,
}
response = JsonResponse(d, status=200)
response["Access-Control-Allow-Origin"] = "*"
return response
return JsonResponse({}, status=404)
data = {
"algorithm": ALGORITHM,
"document": json.dumps(doc)
}
d = {
'@context': ['https://ereuse.org/proof0.json'],
'data': data,
}
response = JsonResponse(d, status=200)
response["Access-Control-Allow-Origin"] = "*"
return response