Add evidence details view
This commit is contained in:
parent
f3117e2f00
commit
0c6a20fbad
|
@ -59,7 +59,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<header class="navbar navbar-dark sticky-top admin bg-green flex-md-nowrap p-0 shadow">
|
||||
<a class="navbar-brand col-md-3 col-lg-2 me-0 px-3" href="#">DEVICE HUB</a>
|
||||
<a class="navbar-brand col-md-3 col-lg-2 me-0 px-3" href="#">DEVICEHUB</a>
|
||||
<div class="navbar-nav navbar-sub-brand">
|
||||
PANGEA
|
||||
</div>
|
||||
|
|
|
@ -200,7 +200,7 @@
|
|||
<small class="text-muted">{{ snap.created }}</small>
|
||||
</div>
|
||||
<p class="mb-1">
|
||||
{{ snap.uuid }}<br />
|
||||
<a href="{% url 'evidence:details' snap.uuid %}">{{ snap.uuid }}</a>
|
||||
</p>
|
||||
<small class="text-muted">
|
||||
</small>
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h3>{{ object.id }}</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<ul class="nav nav-tabs nav-tabs-bordered">
|
||||
<li class="nav-items">
|
||||
<button class="nav-link active" data-bs-toggle="tab" data-bs-target="#device">Devices</button>
|
||||
</li>
|
||||
<li class="nav-items">
|
||||
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#tag">Tag</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-content pt-2">
|
||||
|
||||
<div class="tab-pane fade show active" id="device">
|
||||
<h5 class="card-title">List of chids</h5>
|
||||
<div class="list-group col-6">
|
||||
{% for snap in object.annotations %}
|
||||
{% if snap.type == 0 %}
|
||||
<div class="list-group-item">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<h5 class="mb-1"></h5>
|
||||
<small class="text-muted">
|
||||
{{ snap.created }}
|
||||
</small>
|
||||
</div>
|
||||
<p class="mb-1">
|
||||
{{ snap.key }}<br />
|
||||
</p>
|
||||
<small class="text-muted">
|
||||
<a href="{% url 'device:details' snap.value %}">{{ snap.value }}</a>
|
||||
</small>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -14,7 +14,7 @@
|
|||
{% for ev in evidences %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{# url 'evidence:details' ev #}">{{ ev }}</a>
|
||||
<a href="{% url 'evidence:details' ev %}">{{ ev }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="{# url 'evidence:delete' ev #}"><i class="bi bi-trash text-danger"></i></a>
|
||||
|
|
|
@ -16,4 +16,5 @@ app_name = 'evidence'
|
|||
urlpatterns = [
|
||||
path("", views.ListEvidencesView.as_view(), name="list"),
|
||||
path("upload", views.UploadView.as_view(), name="upload"),
|
||||
path("<uuid:pk>", views.EvidenceView.as_view(), name="details"),
|
||||
]
|
||||
|
|
|
@ -5,7 +5,7 @@ from django.views.generic.edit import (
|
|||
FormView,
|
||||
)
|
||||
|
||||
from dashboard.mixins import DashboardView
|
||||
from dashboard.mixins import DashboardView, Http403
|
||||
from evidence.models import Evidence
|
||||
from evidence.forms import UploadForm
|
||||
# from django.shortcuts import render
|
||||
|
@ -50,3 +50,26 @@ class UploadView(DashboardView, FormView):
|
|||
def form_invalid(self, form):
|
||||
response = super().form_invalid(form)
|
||||
return response
|
||||
|
||||
|
||||
class EvidenceView(DashboardView, TemplateView):
|
||||
template_name = "ev_details.html"
|
||||
section = "evidences"
|
||||
title = _("Evidences")
|
||||
breadcrumb = "Evidences / Details"
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
self.pk = kwargs['pk']
|
||||
self.object = Evidence(self.pk)
|
||||
if self.object.owner != self.request.user:
|
||||
raise Http403
|
||||
|
||||
self.object.get_annotations()
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context.update({
|
||||
'object': self.object,
|
||||
})
|
||||
return context
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
from django import forms
|
||||
|
||||
|
||||
class MultipleFileInput(forms.ClearableFileInput):
|
||||
allow_multiple_selected = True
|
||||
|
||||
|
||||
class MultipleFileField(forms.FileField):
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs.setdefault("widget", MultipleFileInput())
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def clean(self, data, initial=None):
|
||||
single_file_clean = super().clean
|
||||
if isinstance(data, (list, tuple)):
|
||||
result = [single_file_clean(d, initial) for d in data]
|
||||
else:
|
||||
result = [single_file_clean(data, initial)]
|
||||
return result
|
Loading…
Reference in New Issue