xapian #1

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

View File

@ -43,11 +43,11 @@ class Device:
self.get_hids() self.get_hids()
self.get_evidences() self.get_evidences()
self.get_lots() self.get_lots()
def get_annotations(self): def get_annotations(self):
if self.annotations: if self.annotations:
return self.annotations return self.annotations
self.annotations = Annotation.objects.filter( self.annotations = Annotation.objects.filter(
type=Annotation.Type.SYSTEM, type=Annotation.Type.SYSTEM,
value=self.id value=self.id
@ -69,7 +69,7 @@ class Device:
type=Annotation.Type.USER type=Annotation.Type.USER
) )
return annotations return annotations
def get_user_documents(self): def get_user_documents(self):
if not self.uuids: if not self.uuids:
self.get_uuids() self.get_uuids()
@ -80,7 +80,7 @@ class Device:
type=Annotation.Type.DOCUMENT type=Annotation.Type.DOCUMENT
) )
return annotations return annotations
def get_uuids(self): def get_uuids(self):
for a in self.get_annotations(): for a in self.get_annotations():
if a.uuid not in self.uuids: if a.uuid not in self.uuids:
@ -125,6 +125,18 @@ class Device:
# owner=user # owner=user
# ).annotate(num_lots=models.Count('lot')).filter(num_lots=0) # ).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 @property
def manufacturer(self): def manufacturer(self):
if not self.last_evidence: if not self.last_evidence:

View File

@ -49,6 +49,14 @@
<div class="col-lg-9 col-md-8">{{ object.type }}</div> <div class="col-lg-9 col-md-8">{{ object.type }}</div>
</div> </div>
{% if object.is_websnapshot %}
{% for k, v in object.last_user_evidence %}
<div class="row">
<div class="col-lg-3 col-md-4 label">{{ k }}</div>
<div class="col-lg-9 col-md-8">{{ v|default:"" }}</div>
</div>
{% endfor %}
{% else %}
<div class="row"> <div class="row">
<div class="col-lg-3 col-md-4 label">Manufacturer</div> <div class="col-lg-3 col-md-4 label">Manufacturer</div>
<div class="col-lg-9 col-md-8">{{ object.manufacturer|default:"" }}</div> <div class="col-lg-9 col-md-8">{{ object.manufacturer|default:"" }}</div>
@ -63,6 +71,7 @@
<div class="col-lg-3 col-md-4 label">Serial Number</div> <div class="col-lg-3 col-md-4 label">Serial Number</div>
<div class="col-lg-9 col-md-8">{{ object.last_evidence.doc.device.serialNumber|default:"" }}</div> <div class="col-lg-9 col-md-8">{{ object.last_evidence.doc.device.serialNumber|default:"" }}</div>
</div> </div>
{% endif %}
<div class="row"> <div class="row">
<div class="col-lg-3 col-md-4 label">Identifiers</div> <div class="col-lg-3 col-md-4 label">Identifiers</div>
</div> </div>