From 4abd063a61d0642017144bebe0f9aa18306c7a4f Mon Sep 17 00:00:00 2001 From: Lance Tan Date: Thu, 30 Nov 2023 15:25:04 -0800 Subject: [PATCH] Fix --- backend/auction/models.py | 6 ------ backend/vehicle/models.py | 39 ++++++++++++++++++--------------------- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/backend/auction/models.py b/backend/auction/models.py index f710123..304350d 100644 --- a/backend/auction/models.py +++ b/backend/auction/models.py @@ -38,12 +38,6 @@ class AuctionItem(MainModel): class Meta: unique_together = ("auction_id", "content_type", "object_id") - def clean(self): - # Restrict content_type to specific models - valid_models = ["vehicle", "equipment", "trailer"] - if self.content_type.model not in valid_models: - raise ValidationError(f"ContentType must be one of {valid_models}") - def save(self, *args, **kwargs): self.clean() super().save(*args, **kwargs) diff --git a/backend/vehicle/models.py b/backend/vehicle/models.py index fcd248f..5d2ac2e 100644 --- a/backend/vehicle/models.py +++ b/backend/vehicle/models.py @@ -24,13 +24,18 @@ class Vehicle(MainModel): minimum_price = models.IntegerField(blank=True, null=True) is_sold = models.BooleanField(default=False) remarks = models.CharField(max_length=2000, blank=True, null=True) - classification_type = models.CharField(max_length=50, blank=True, null=True) + classification_type = models.CharField( + max_length=50, blank=True, null=True) engine_condition = models.CharField(max_length=100, blank=True, null=True) - transmission_condition = models.CharField(max_length=100, blank=True, null=True) - differentials_condition = models.CharField(max_length=100, blank=True, null=True) + transmission_condition = models.CharField( + max_length=100, blank=True, null=True) + differentials_condition = models.CharField( + max_length=100, blank=True, null=True) brake_condition = models.CharField(max_length=100, blank=True, null=True) - electrical_condition = models.CharField(max_length=100, blank=True, null=True) - operating_system_condition = models.CharField(max_length=100, blank=True, null=True) + electrical_condition = models.CharField( + max_length=100, blank=True, null=True) + operating_system_condition = models.CharField( + max_length=100, blank=True, null=True) chassis_condition = models.CharField(max_length=100, blank=True, null=True) body_condition = models.CharField(max_length=100, blank=True, null=True) @@ -44,12 +49,16 @@ class Equipment(MainModel): brand = models.ForeignKey(Brand, on_delete=models.PROTECT) equipment_type = models.ForeignKey(Type, on_delete=models.PROTECT) location = models.CharField(max_length=50, blank=True, null=True) - classification_type = models.CharField(max_length=50, blank=True, null=True) + classification_type = models.CharField( + max_length=50, blank=True, null=True) engine_condition = models.CharField(max_length=100, blank=True, null=True) - transmission_condition = models.CharField(max_length=100, blank=True, null=True) - differentials_condition = models.CharField(max_length=100, blank=True, null=True) + transmission_condition = models.CharField( + max_length=100, blank=True, null=True) + differentials_condition = models.CharField( + max_length=100, blank=True, null=True) brake_condition = models.CharField(max_length=100, blank=True, null=True) - electrical_condition = models.CharField(max_length=100, blank=True, null=True) + electrical_condition = models.CharField( + max_length=100, blank=True, null=True) hydraulic_cylinder_condition = models.CharField( max_length=100, blank=True, null=True ) @@ -79,12 +88,6 @@ class UnitImage(MainModel): object_id = models.UUIDField() content_object = GenericForeignKey("content_type", "object_id") - def clean(self): - # Restrict content_type to specific models - valid_models = ["vehicle", "equipment", "trailer"] - if self.content_type.model not in valid_models: - raise ValidationError(f"ContentType must be one of {valid_models}") - def save(self, *args, **kwargs): self.clean() super().save(*args, **kwargs) @@ -100,12 +103,6 @@ class SavedUnits(MainModel): class Meta: unique_together = ("auction_id", "bidder_id", "object_id") - def clean(self): - # Restrict content_type to specific models - valid_models = ["vehicle", "equipment", "trailer"] - if self.content_type.model not in valid_models: - raise ValidationError(f"ContentType must be one of {valid_models}") - def save(self, *args, **kwargs): self.clean() super().save(*args, **kwargs)