Add get_serial_number() method
This commit is contained in:
parent
7db879e189
commit
8cb66104ca
|
@ -19,14 +19,16 @@ class Annotation(models.Model):
|
||||||
created = models.DateTimeField(auto_now_add=True)
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
uuid = models.UUIDField()
|
uuid = models.UUIDField()
|
||||||
owner = models.ForeignKey(Institution, on_delete=models.CASCADE)
|
owner = models.ForeignKey(Institution, on_delete=models.CASCADE)
|
||||||
user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True)
|
user = models.ForeignKey(
|
||||||
|
User, on_delete=models.SET_NULL, null=True, blank=True)
|
||||||
type = models.SmallIntegerField(choices=Type)
|
type = models.SmallIntegerField(choices=Type)
|
||||||
key = models.CharField(max_length=STR_EXTEND_SIZE)
|
key = models.CharField(max_length=STR_EXTEND_SIZE)
|
||||||
value = models.CharField(max_length=STR_EXTEND_SIZE)
|
value = models.CharField(max_length=STR_EXTEND_SIZE)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
constraints = [
|
constraints = [
|
||||||
models.UniqueConstraint(fields=["type", "key", "uuid"], name="unique_type_key_uuid")
|
models.UniqueConstraint(
|
||||||
|
fields=["type", "key", "uuid"], name="unique_type_key_uuid")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,7 +89,7 @@ class Evidence:
|
||||||
return self.components
|
return self.components
|
||||||
|
|
||||||
def get_manufacturer(self):
|
def get_manufacturer(self):
|
||||||
if self.doc.get("type") == "WebSnapshot":
|
if self.is_new_snapshot():
|
||||||
kv = self.doc.get('kv', {})
|
kv = self.doc.get('kv', {})
|
||||||
if len(kv) < 1:
|
if len(kv) < 1:
|
||||||
return ""
|
return ""
|
||||||
|
@ -99,7 +101,7 @@ class Evidence:
|
||||||
return self.dmi.manufacturer().strip()
|
return self.dmi.manufacturer().strip()
|
||||||
|
|
||||||
def get_model(self):
|
def get_model(self):
|
||||||
if self.doc.get("type") == "WebSnapshot":
|
if self.is_new_snapshot():
|
||||||
kv = self.doc.get('kv', {})
|
kv = self.doc.get('kv', {})
|
||||||
if len(kv) < 2:
|
if len(kv) < 2:
|
||||||
return ""
|
return ""
|
||||||
|
@ -122,6 +124,11 @@ class Evidence:
|
||||||
return k
|
return k
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
def get_serial_number(self):
|
||||||
|
if self.is_legacy():
|
||||||
|
return self.doc['device']['serialNumber']
|
||||||
|
return self.dmi.serial_number().strip()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_all(cls, user):
|
def get_all(cls, user):
|
||||||
return Annotation.objects.filter(
|
return Annotation.objects.filter(
|
||||||
|
@ -136,3 +143,6 @@ class Evidence:
|
||||||
|
|
||||||
def is_legacy(self):
|
def is_legacy(self):
|
||||||
return self.doc.get("software") != "workbench-script"
|
return self.doc.get("software") != "workbench-script"
|
||||||
|
|
||||||
|
def is_new_snapshot(self):
|
||||||
|
return self.doc.get("type") == "WebSnapshot"
|
||||||
|
|
Loading…
Reference in New Issue