From e96afda483bca4292fb066e07f194951bedc64b2 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 26 Sep 2024 13:09:55 +0200 Subject: [PATCH] add details in dashboard for placeholder --- device/models.py | 11 ++++++----- evidence/models.py | 12 ++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/device/models.py b/device/models.py index 683da53..6ffae4a 100644 --- a/device/models.py +++ b/device/models.py @@ -131,14 +131,14 @@ class Device: def is_websnapshot(self): if not self.last_evidence: self.get_last_evidence() - return self.last_evidence.doc['type'] == "WebSnapshot" - + 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: @@ -147,6 +147,9 @@ class Device: @property def type(self): + 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() @@ -162,5 +165,3 @@ class Device: if not self.last_evidence: self.get_last_evidence() return self.last_evidence.get_components() - - diff --git a/evidence/models.py b/evidence/models.py index 031641f..2f0c703 100644 --- a/evidence/models.py +++ b/evidence/models.py @@ -83,12 +83,24 @@ class Evidence: return self.components def get_manufacturer(self): + if self.doc.get("type") == "WebSnapshot": + kv = self.doc.get('kv', {}) + if len(kv) < 1: + return "" + return list(self.doc.get('kv').values())[0] + if self.doc.get("software") != "EreuseWorkbench": return self.doc['device']['manufacturer'] return self.dmi.manufacturer().strip() def get_model(self): + if self.doc.get("type") == "WebSnapshot": + kv = self.doc.get('kv', {}) + if len(kv) < 2: + return "" + return list(self.doc.get('kv').values())[1] + if self.doc.get("software") != "EreuseWorkbench": return self.doc['device']['model']