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 1910609f68 - Show all commits

View file

@ -1,3 +1,4 @@
import logging
from django.views.generic.edit import View from django.views.generic.edit import View
from django.http import JsonResponse from django.http import JsonResponse
@ -6,10 +7,16 @@ from dpp.models import Proof
from dpp.api_dlt import ALGORITHM from dpp.api_dlt import ALGORITHM
logger = logging.getLogger('django')
class ProofView(View): class ProofView(View):
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
timestamp = kwargs.get("proof_id") timestamp = kwargs.get("proof_id")
for p in Proof.objects.filter():
logger.error(p.timestamp)
proof = Proof.objects.filter(timestamp=timestamp).first() proof = Proof.objects.filter(timestamp=timestamp).first()
if not proof: if not proof:
return JsonResponse({}, status=404) return JsonResponse({}, status=404)
@ -31,6 +38,9 @@ class ProofView(View):
'@context': ['https://ereuse.org/proof0.json'], '@context': ['https://ereuse.org/proof0.json'],
'data': data, 'data': data,
} }
return JsonResponse(d, status=200) response = JsonResponse(d, status=200)
response["Access-Control-Allow-Origin"] = "*"
return response
return JsonResponse({}, status=404) return JsonResponse({}, status=404)