fixed models confusion
This commit is contained in:
parent
e35e6414aa
commit
22d4cea560
|
@ -10,17 +10,6 @@ class State(models.Model):
|
||||||
state = models.CharField(max_length=50)
|
state = models.CharField(max_length=50)
|
||||||
snapshot_uuid = models.UUIDField()
|
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):
|
def clean(self):
|
||||||
if not StateDefinition.objects.filter(institution=self.institution, state=self.state).exists():
|
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}'.")
|
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()
|
self.clean()
|
||||||
super().save(*args, **kwargs)
|
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):
|
def __str__(self):
|
||||||
return f"{self.institution.name} - {self.state}"
|
return f"{self.institution.name} - {self.state}"
|
||||||
|
|
Loading…
Reference in a new issue