diff --git a/.env.example b/.env.example index ed60e95..d8fed15 100644 --- a/.env.example +++ b/.env.example @@ -3,6 +3,7 @@ DEMO=true # note that with DEBUG=true, logs are more verbose (include tracebacks) DEBUG=true ALLOWED_HOSTS=localhost,localhost:8000,127.0.0.1, +DPP=false STATIC_ROOT=/tmp/static/ MEDIA_ROOT=/tmp/media/ diff --git a/device/models.py b/device/models.py index 4e0778f..cd77389 100644 --- a/device/models.py +++ b/device/models.py @@ -25,6 +25,7 @@ class Device: def __init__(self, *args, **kwargs): # the id is the chid of the device self.id = kwargs["id"] + self.uuid = kwargs.get("uuid") self.pk = self.id self.shortid = self.pk[:6].upper() self.algorithm = None @@ -103,11 +104,19 @@ class Device: self.evidences = [Evidence(u) for u in self.uuids] def get_last_evidence(self): + if self.last_evidence: + return + + if self.uuid: + self.last_evidence = Evidence(self.uuid) + return + annotations = self.get_annotations() if not annotations.count(): return annotation = annotations.first() self.last_evidence = Evidence(annotation.uuid) + self.uuid = annotation.uuid def is_eraseserver(self): if not self.uuids: @@ -126,6 +135,8 @@ class Device: return False def last_uuid(self): + if self.uuid: + return self.uuid return self.uuids[0] def get_lots(self): @@ -263,45 +274,38 @@ class Device: @property def is_websnapshot(self): - if not self.last_evidence: - self.get_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() + self.get_last_evidence() return self.last_evidence.doc['kv'].items() @property def manufacturer(self): - if not self.last_evidence: - self.get_last_evidence() + self.get_last_evidence() return self.last_evidence.get_manufacturer() @property def serial_number(self): - if not self.last_evidence: - self.get_last_evidence() + self.get_last_evidence() return self.last_evidence.get_serial_number() @property def type(self): + self.get_last_evidence() if self.last_evidence.doc['type'] == "WebSnapshot": return self.last_evidence.doc.get("device", {}).get("type", "") - if not self.last_evidence: - self.get_last_evidence() return self.last_evidence.get_chassis() @property def model(self): - if not self.last_evidence: - self.get_last_evidence() + self.get_last_evidence() return self.last_evidence.get_model() @property def components(self): - if not self.last_evidence: - self.get_last_evidence() + self.get_last_evidence() return self.last_evidence.get_components() diff --git a/device/templates/details.html b/device/templates/details.html index 137a4f6..99346c9 100644 --- a/device/templates/details.html +++ b/device/templates/details.html @@ -29,6 +29,11 @@
+ {% for component_key, component_value in component.items %}
+ {% if component_key not in 'actions,type' %}
+ {% if component_key != 'serialNumber' or user.is_authenticated %}
+ {{ component_key }}: {{ component_value }}
+ {% endif %}
+ {% endif %}
+ {% endfor %}
+