diff --git a/backend/auction/models.py b/backend/auction/models.py index 79c9734..d9ea264 100644 --- a/backend/auction/models.py +++ b/backend/auction/models.py @@ -1,7 +1,7 @@ -from django.db import models from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ValidationError +from django.db import models from core.models import MainModel @@ -36,11 +36,11 @@ class AuctionItem(MainModel): content_object = GenericForeignKey("content_type", "object_id") class Meta: - unique_together = ('auction_id', 'content_type', 'object_id') + unique_together = ("auction_id", "content_type", "object_id") def clean(self): # Restrict content_type to specific models - valid_models = ['vehicle', 'equipment', 'trailer'] + valid_models = ["vehicle", "equipment", "trailer"] if self.content_type.model not in valid_models: raise ValidationError(f"ContentType must be one of {valid_models}") diff --git a/backend/bid/models.py b/backend/bid/models.py index f0edcbd..4b8b50b 100644 --- a/backend/bid/models.py +++ b/backend/bid/models.py @@ -21,7 +21,7 @@ class Bid(MainModel): def clean(self): # Restrict content_type to specific models - valid_models = ['vehicle', 'equipment', 'trailer'] + valid_models = ["vehicle", "equipment", "trailer"] if self.content_type.model not in valid_models: raise ValidationError(f"ContentType must be one of {valid_models}") diff --git a/backend/vehicle/models.py b/backend/vehicle/models.py index 40a07dd..fcd248f 100644 --- a/backend/vehicle/models.py +++ b/backend/vehicle/models.py @@ -81,7 +81,7 @@ class UnitImage(MainModel): def clean(self): # Restrict content_type to specific models - valid_models = ['vehicle', 'equipment', 'trailer'] + valid_models = ["vehicle", "equipment", "trailer"] if self.content_type.model not in valid_models: raise ValidationError(f"ContentType must be one of {valid_models}") @@ -98,14 +98,14 @@ class SavedUnits(MainModel): content_object = GenericForeignKey("content_type", "object_id") class Meta: - unique_together = ('auction_id', 'bidder_id', 'object_id') + unique_together = ("auction_id", "bidder_id", "object_id") def clean(self): # Restrict content_type to specific models - valid_models = ['vehicle', 'equipment', 'trailer'] + 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) \ No newline at end of file + super().save(*args, **kwargs)