96-add-serial-number-in-public-web #24

Merged
cayop merged 10 commits from 96-add-serial-number-in-public-web into main 2024-11-06 16:30:19 +00:00
1 changed files with 11 additions and 5 deletions
Showing only changes of commit a67fda6b51 - Show all commits

View File

@ -29,7 +29,7 @@ class Device:
self.shortid = self.pk[:6].upper() self.shortid = self.pk[:6].upper()
self.algorithm = None self.algorithm = None
self.owner = None self.owner = None
self.annotations = [] self.annotations = []
self.hids = [] self.hids = []
self.uuids = [] self.uuids = []
self.evidences = [] self.evidences = []
@ -108,7 +108,7 @@ class Device:
return return
annotation = annotations.first() annotation = annotations.first()
self.last_evidence = Evidence(annotation.uuid) self.last_evidence = Evidence(annotation.uuid)
def is_eraseserver(self): def is_eraseserver(self):
if not self.uuids: if not self.uuids:
self.get_uuids() self.get_uuids()
@ -120,7 +120,7 @@ class Device:
owner=self.owner, owner=self.owner,
type=Annotation.Type.ERASE_SERVER type=Annotation.Type.ERASE_SERVER
).first() ).first()
if annotation: if annotation:
return True return True
return False return False
@ -129,7 +129,8 @@ class Device:
return self.uuids[0] return self.uuids[0]
def get_lots(self): 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 @classmethod
def get_unassigned(cls, institution, offset=0, limit=None): def get_unassigned(cls, institution, offset=0, limit=None):
@ -179,7 +180,6 @@ class Device:
count = cls.get_unassigned_count(institution) count = cls.get_unassigned_count(institution)
return devices, count return devices, count
@classmethod @classmethod
def get_unassigned_count(cls, institution): def get_unassigned_count(cls, institution):
@ -279,6 +279,12 @@ class Device:
self.get_last_evidence() self.get_last_evidence()
return self.last_evidence.get_manufacturer() 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 @property
def type(self): def type(self):
if self.last_evidence.doc['type'] == "WebSnapshot": if self.last_evidence.doc['type'] == "WebSnapshot":