From 22d4cea5600729d345b657474d1befbf8da3146a Mon Sep 17 00:00:00 2001 From: Thomas Rusiecki Date: Sun, 1 Dec 2024 17:54:22 -0300 Subject: [PATCH] fixed models confusion --- action/models.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/action/models.py b/action/models.py index 25be31d..c6dc47f 100644 --- a/action/models.py +++ b/action/models.py @@ -10,17 +10,6 @@ class State(models.Model): state = models.CharField(max_length=50) snapshot_uuid = models.UUIDField() - class Meta: - unique_together = ('institution', 'state') - - def __str__(self): - return f"{self.institution.name} - {self.state} - {self.snapshot_uuid}" - -class StateDefinition(models.Model): - institution = models.ForeignKey(Institution, on_delete=models.CASCADE) - order = models.AutoField(primary_key=True) - state = models.CharField(max_length=50) - def clean(self): if not StateDefinition.objects.filter(institution=self.institution, state=self.state).exists(): raise ValidationError(f"The state '{self.state}' is not valid for the institution '{self.institution.name}'.") @@ -29,5 +18,16 @@ class StateDefinition(models.Model): self.clean() super().save(*args, **kwargs) + def __str__(self): + return f"{self.institution.name} - {self.state} - {self.snapshot_uuid}" + +class StateDefinition(models.Model): + institution = models.ForeignKey(Institution, on_delete=models.CASCADE) + order = models.AutoField(primary_key=True) + state = models.CharField(max_length=50) + + class Meta: + unique_together = ('institution', 'state') + def __str__(self): return f"{self.institution.name} - {self.state}"