diff --git a/evidence/templates/ev_details.html b/evidence/templates/ev_details.html
index e589d2f..4c3fdbf 100644
--- a/evidence/templates/ev_details.html
+++ b/evidence/templates/ev_details.html
@@ -16,6 +16,9 @@
+
+ Download File
+
diff --git a/evidence/urls.py b/evidence/urls.py
index 060ce52..872073a 100644
--- a/evidence/urls.py
+++ b/evidence/urls.py
@@ -17,4 +17,5 @@ urlpatterns = [
path("", views.ListEvidencesView.as_view(), name="list"),
path("upload", views.UploadView.as_view(), name="upload"),
path("", views.EvidenceView.as_view(), name="details"),
+ path("/download", views.DownloadEvidenceView.as_view(), name="download"),
]
diff --git a/evidence/views.py b/evidence/views.py
index a9459e1..d5ff542 100644
--- a/evidence/views.py
+++ b/evidence/views.py
@@ -1,3 +1,6 @@
+import json
+
+from django.http import HttpResponse
from django.utils.translation import gettext_lazy as _
from django.views.generic.base import TemplateView
from django.urls import reverse_lazy
@@ -94,3 +97,18 @@ class EvidenceView(DashboardView, FormView):
def get_success_url(self):
success_url = reverse_lazy('evidence:details', args=[self.pk])
return success_url
+
+
+class DownloadEvidenceView(DashboardView, TemplateView):
+
+ def get(self, request, *args, **kwargs):
+ pk = kwargs['pk']
+ evidence = Evidence(pk)
+ if evidence.owner != self.request.user:
+ raise Http403()
+
+ evidence.get_doc()
+ data = json.dumps(evidence.doc)
+ response = HttpResponse(data, content_type="application/json")
+ response['Content-Disposition'] = 'attachment; filename={}'.format("credential.json")
+ return response