add coming soon feature
This commit is contained in:
parent
5c626b0212
commit
bde13d4d95
5 changed files with 42 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue