xapian #1

Merged
cayop merged 26 commits from xapian into master 2024-09-17 10:11:28 +00:00
3 changed files with 22 additions and 0 deletions
Showing only changes of commit e2f9855954 - Show all commits

View File

@ -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>

View File

@ -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"),
] ]

View File

@ -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