xapian #1
|
@ -16,6 +16,9 @@
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-items">
|
<li class="nav-items">
|
||||||
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#tag">Tag</button>
|
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#tag">Tag</button>
|
||||||
|
<li class="nav-items">
|
||||||
|
<a href="{% url 'evidence:download' object.uuid %}" class="nav-link">Download File</a>
|
||||||
|
</li>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -17,4 +17,5 @@ urlpatterns = [
|
||||||
path("", views.ListEvidencesView.as_view(), name="list"),
|
path("", views.ListEvidencesView.as_view(), name="list"),
|
||||||
path("upload", views.UploadView.as_view(), name="upload"),
|
path("upload", views.UploadView.as_view(), name="upload"),
|
||||||
path("<uuid:pk>", views.EvidenceView.as_view(), name="details"),
|
path("<uuid:pk>", views.EvidenceView.as_view(), name="details"),
|
||||||
|
path("<uuid:pk>/download", views.DownloadEvidenceView.as_view(), name="download"),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
import json
|
||||||
|
|
||||||
|
from django.http import HttpResponse
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.views.generic.base import TemplateView
|
from django.views.generic.base import TemplateView
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
|
@ -94,3 +97,18 @@ class EvidenceView(DashboardView, FormView):
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
success_url = reverse_lazy('evidence:details', args=[self.pk])
|
success_url = reverse_lazy('evidence:details', args=[self.pk])
|
||||||
return success_url
|
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
|
||||||
|
|
Loading…
Reference in New Issue