From 31d90a6e98b1da799dd916172b289a7a6921e7dc Mon Sep 17 00:00:00 2001 From: Thomas Rusiecki Date: Wed, 18 Dec 2024 12:57:36 -0300 Subject: [PATCH] notes and log models added --- action/models.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/action/models.py b/action/models.py index 6a5f76f..7c3fa07 100644 --- a/action/models.py +++ b/action/models.py @@ -52,3 +52,30 @@ class StateDefinition(models.Model): def __str__(self): return f"{self.institution.name} - {self.state}" + + +class Note(models.Model): + institution = models.ForeignKey(Institution, on_delete=models.CASCADE) + user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True) + date = models.DateTimeField(auto_now_add=True) + description = models.TextField(max_lenght=250) + snapshot_uuid = models.UUIDField() + + class Meta: + ordering = ['-date'] + + def __str__(self): + return f" Note: {self.description}, by {self.user.username} @ {self.user.institution} - {self.date}, for {self.snapshot_uuid}" + +class DeviceLog(models.Model): + institution = models.ForeignKey(Institution, on_delete=models.CASCADE) + user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True) + date = models.DateTimeField(auto_now_add=True) + event = models.CharField(max_length=255) + snapshot_uuid = models.UUIDField() + + class Meta: + ordering = ['-date'] + + def __str__(self): + return f"{self.event} by {self.user.username} @ {self.institution.name} - {self.date}, for {self.snapshot_uuid}"