add coming soon feature

This commit is contained in:
Tobias Brunner 2025-02-26 15:27:56 +01:00
parent 5c626b0212
commit bde13d4d95
No known key found for this signature in database
5 changed files with 42 additions and 1 deletions

View file

@ -107,13 +107,22 @@ class Service(models.Model):
categories = models.ManyToManyField(Category, related_name="services")
features = ProseEditorField()
is_featured = models.BooleanField(default=False)
is_coming_soon = models.BooleanField(default=False)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return self.name
def clean(self):
if self.is_featured and self.is_coming_soon:
raise ValidationError(
"A service cannot be both featured and coming soon simultaneously."
)
super().clean()
def save(self, *args, **kwargs):
self.clean() # Ensure validation runs on save
if not self.slug:
self.slug = slugify(self.name)
counter = 1