Compare commits
3 Commits
main
...
96-add-ser
Author | SHA1 | Date |
---|---|---|
sergio_gimenez | 915d95379c | |
sergio_gimenez | 8cb66104ca | |
sergio_gimenez | 7db879e189 |
|
@ -29,7 +29,7 @@ class Device:
|
|||
self.shortid = self.pk[:6].upper()
|
||||
self.algorithm = None
|
||||
self.owner = None
|
||||
self.annotations = []
|
||||
self.annotations = []
|
||||
self.hids = []
|
||||
self.uuids = []
|
||||
self.evidences = []
|
||||
|
@ -108,7 +108,7 @@ class Device:
|
|||
return
|
||||
annotation = annotations.first()
|
||||
self.last_evidence = Evidence(annotation.uuid)
|
||||
|
||||
|
||||
def is_eraseserver(self):
|
||||
if not self.uuids:
|
||||
self.get_uuids()
|
||||
|
@ -120,7 +120,7 @@ class Device:
|
|||
owner=self.owner,
|
||||
type=Annotation.Type.ERASE_SERVER
|
||||
).first()
|
||||
|
||||
|
||||
if annotation:
|
||||
return True
|
||||
return False
|
||||
|
@ -129,7 +129,8 @@ class Device:
|
|||
return self.uuids[0]
|
||||
|
||||
def get_lots(self):
|
||||
self.lots = [x.lot for x in DeviceLot.objects.filter(device_id=self.id)]
|
||||
self.lots = [
|
||||
x.lot for x in DeviceLot.objects.filter(device_id=self.id)]
|
||||
|
||||
@classmethod
|
||||
def get_unassigned(cls, institution, offset=0, limit=None):
|
||||
|
@ -179,7 +180,6 @@ class Device:
|
|||
count = cls.get_unassigned_count(institution)
|
||||
return devices, count
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_unassigned_count(cls, institution):
|
||||
|
||||
|
@ -279,6 +279,12 @@ class Device:
|
|||
self.get_last_evidence()
|
||||
return self.last_evidence.get_manufacturer()
|
||||
|
||||
@property
|
||||
def serial_number(self):
|
||||
if not self.last_evidence:
|
||||
self.get_last_evidence()
|
||||
return self.last_evidence.get_serial_number()
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
if self.last_evidence.doc['type'] == "WebSnapshot":
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
<div class="col-lg-3 col-md-4 label">
|
||||
{% trans '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.serial_number|default:'' }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ from user.models import User, Institution
|
|||
|
||||
class Annotation(models.Model):
|
||||
class Type(models.IntegerChoices):
|
||||
SYSTEM= 0, "System"
|
||||
SYSTEM = 0, "System"
|
||||
USER = 1, "User"
|
||||
DOCUMENT = 2, "Document"
|
||||
ERASE_SERVER = 3, "EraseServer"
|
||||
|
@ -19,14 +19,16 @@ class Annotation(models.Model):
|
|||
created = models.DateTimeField(auto_now_add=True)
|
||||
uuid = models.UUIDField()
|
||||
owner = models.ForeignKey(Institution, on_delete=models.CASCADE)
|
||||
user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True)
|
||||
type = models.SmallIntegerField(choices=Type)
|
||||
user = models.ForeignKey(
|
||||
User, on_delete=models.SET_NULL, null=True, blank=True)
|
||||
type = models.SmallIntegerField(choices=Type)
|
||||
key = models.CharField(max_length=STR_EXTEND_SIZE)
|
||||
value = models.CharField(max_length=STR_EXTEND_SIZE)
|
||||
|
||||
class Meta:
|
||||
constraints = [
|
||||
models.UniqueConstraint(fields=["type", "key", "uuid"], name="unique_type_key_uuid")
|
||||
models.UniqueConstraint(
|
||||
fields=["type", "key", "uuid"], name="unique_type_key_uuid")
|
||||
]
|
||||
|
||||
|
||||
|
@ -37,8 +39,8 @@ class Evidence:
|
|||
self.doc = None
|
||||
self.created = None
|
||||
self.dmi = None
|
||||
self.annotations = []
|
||||
self.components = []
|
||||
self.annotations = []
|
||||
self.components = []
|
||||
self.default = "n/a"
|
||||
|
||||
self.get_owner()
|
||||
|
@ -87,7 +89,7 @@ class Evidence:
|
|||
return self.components
|
||||
|
||||
def get_manufacturer(self):
|
||||
if self.doc.get("type") == "WebSnapshot":
|
||||
if self.is_new_snapshot():
|
||||
kv = self.doc.get('kv', {})
|
||||
if len(kv) < 1:
|
||||
return ""
|
||||
|
@ -99,7 +101,7 @@ class Evidence:
|
|||
return self.dmi.manufacturer().strip()
|
||||
|
||||
def get_model(self):
|
||||
if self.doc.get("type") == "WebSnapshot":
|
||||
if self.is_new_snapshot():
|
||||
kv = self.doc.get('kv', {})
|
||||
if len(kv) < 2:
|
||||
return ""
|
||||
|
@ -122,6 +124,11 @@ class Evidence:
|
|||
return k
|
||||
return ""
|
||||
|
||||
def get_serial_number(self):
|
||||
if self.is_legacy():
|
||||
return self.doc['device']['serialNumber']
|
||||
return self.dmi.serial_number().strip()
|
||||
|
||||
@classmethod
|
||||
def get_all(cls, user):
|
||||
return Annotation.objects.filter(
|
||||
|
@ -136,3 +143,6 @@ class Evidence:
|
|||
|
||||
def is_legacy(self):
|
||||
return self.doc.get("software") != "workbench-script"
|
||||
|
||||
def is_new_snapshot(self):
|
||||
return self.doc.get("type") == "WebSnapshot"
|
||||
|
|
Loading…
Reference in New Issue