From e646cdfa5604f8064c4cb9a014a48e69a00dc2b3 Mon Sep 17 00:00:00 2001 From: Thomas Rusiecki Date: Thu, 12 Dec 2024 17:01:21 -0300 Subject: [PATCH] current state helper function added --- device/models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/device/models.py b/device/models.py index 037965c..fabe880 100644 --- a/device/models.py +++ b/device/models.py @@ -3,6 +3,7 @@ from django.db import models, connection from utils.constants import ALGOS from evidence.models import SystemProperty, UserProperty, Evidence from lot.models import DeviceLot +from action.models import State class Device: @@ -137,6 +138,11 @@ class Device: return self.uuid return self.uuids[0] + def get_current_state(self): + uuid = self.last_uuid + + return State.objects.filter(snapshot_uuid=uuid).order_by('-date').first() + def get_lots(self): self.lots = [ x.lot for x in DeviceLot.objects.filter(device_id=self.id)]