From 468abb2c2f9f4ac3796603256f08d62a7531d345 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 5 Aug 2024 15:06:34 +0200 Subject: [PATCH] add evidences in details of device --- device/models.py | 20 ++++++++++++++++---- device/templates/details.html | 9 +++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/device/models.py b/device/models.py index ce874fd..f1b1ee7 100644 --- a/device/models.py +++ b/device/models.py @@ -43,11 +43,11 @@ class Device: self.get_hids() self.get_evidences() self.get_lots() - + def get_annotations(self): if self.annotations: return self.annotations - + self.annotations = Annotation.objects.filter( type=Annotation.Type.SYSTEM, value=self.id @@ -69,7 +69,7 @@ class Device: type=Annotation.Type.USER ) return annotations - + def get_user_documents(self): if not self.uuids: self.get_uuids() @@ -80,7 +80,7 @@ class Device: type=Annotation.Type.DOCUMENT ) return annotations - + def get_uuids(self): for a in self.get_annotations(): if a.uuid not in self.uuids: @@ -125,6 +125,18 @@ class Device: # owner=user # ).annotate(num_lots=models.Count('lot')).filter(num_lots=0) + @property + def is_websnapshot(self): + if not self.last_evidence: + self.get_last_evidence() + return self.last_evidence.doc['type'] == "WebSnapshot" + + @property + def last_user_evidence(self): + if not self.last_evidence: + self.get_last_evidence() + return self.last_evidence.doc['kv'].items() + @property def manufacturer(self): if not self.last_evidence: diff --git a/device/templates/details.html b/device/templates/details.html index 577e823..3881c1a 100644 --- a/device/templates/details.html +++ b/device/templates/details.html @@ -49,6 +49,14 @@
{{ object.type }}
+ {% if object.is_websnapshot %} + {% for k, v in object.last_user_evidence %} +
+
{{ k }}
+
{{ v|default:"" }}
+
+ {% endfor %} + {% else %}
Manufacturer
{{ object.manufacturer|default:"" }}
@@ -63,6 +71,7 @@
Serial Number
{{ object.last_evidence.doc.device.serialNumber|default:"" }}
+ {% endif %}
Identifiers