diff --git a/hub/services/migrations/0007_service_is_coming_soon.py b/hub/services/migrations/0007_service_is_coming_soon.py new file mode 100644 index 0000000..4451a55 --- /dev/null +++ b/hub/services/migrations/0007_service_is_coming_soon.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.5 on 2025-02-26 14:17 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("services", "0006_cloudprovider_is_featured_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="service", + name="is_coming_soon", + field=models.BooleanField(default=False), + ), + ] diff --git a/hub/services/models.py b/hub/services/models.py index 5ac188c..e26654d 100644 --- a/hub/services/models.py +++ b/hub/services/models.py @@ -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 diff --git a/hub/services/templates/services/lead_form.html b/hub/services/templates/services/lead_form.html index 65f8920..177fdcf 100644 --- a/hub/services/templates/services/lead_form.html +++ b/hub/services/templates/services/lead_form.html @@ -8,7 +8,7 @@