some fields validation and model cleaning
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
+9
-1
@@ -1,8 +1,12 @@
|
||||
from django.db import models
|
||||
|
||||
from common.fields import ContainerNumberField
|
||||
from containers.models import Container
|
||||
|
||||
|
||||
# Create your models here.
|
||||
class Preinfo(models.Model):
|
||||
container_number = models.CharField(
|
||||
container_number = ContainerNumberField(
|
||||
max_length=11,
|
||||
)
|
||||
container_type = models.ForeignKey(
|
||||
@@ -33,3 +37,7 @@ class Preinfo(models.Model):
|
||||
)
|
||||
deleted_on = models.DateTimeField(null=True, blank=True)
|
||||
received = models.BooleanField(default=False, null=False)
|
||||
|
||||
def clean(self):
|
||||
if Container.objects.filter(number=self.container_number, expedited=False).exists():
|
||||
raise ValueError(f'Container with number {self.container_number} is at the depot.')
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user