From 5e492e0210f055b3b0a0f20178c53946b3366972 Mon Sep 17 00:00:00 2001 From: Thomas Rusiecki Date: Sat, 30 Nov 2024 04:38:19 -0300 Subject: [PATCH] initial orm state models --- action/models.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/action/models.py b/action/models.py index 71a8362..b28f7af 100644 --- a/action/models.py +++ b/action/models.py @@ -1,3 +1,22 @@ -from django.db import models +from django.db import models, connection +from user.models import User, Institution -# Create your models here. + +class StateDefinition(models.Model): + institution = models.ForeignKey(Institution, on_delete=models.CASCADE) + order = models.PositiveIntegerField() + state = models.CharField(max_length=255) + + def __str__(self): + return f"{self.institution.name} - {self.state}" + +class State(models.Model): + date = models.DateTimeField(auto_now_add=True) + institution = models.ForeignKey(Institution, on_delete=models.CASCADE) + user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True) + + state = models.CharField(max_length=255) + snapshot_uuid = models.UUIDField() + + def __str__(self): + return f"{self.institution.name} - {self.state} - {self.snapshot_uuid}"