52 lines
1.9 KiB
Python
52 lines
1.9 KiB
Python
import uuid
|
|
|
|
from django.conf import settings
|
|
from django.db import models
|
|
|
|
|
|
class TemplateOption(models.Model):
|
|
name = models.CharField(max_length=120)
|
|
slug = models.SlugField(unique=True)
|
|
description = models.TextField(blank=True)
|
|
supports_basic = models.BooleanField(default=True)
|
|
supports_django = models.BooleanField(default=True)
|
|
source_folder = models.CharField(max_length=255, blank=True)
|
|
is_active = models.BooleanField(default=True)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
|
|
class Meta:
|
|
ordering = ["name"]
|
|
|
|
def __str__(self) -> str:
|
|
return self.name
|
|
|
|
|
|
class ClientSite(models.Model):
|
|
class Status(models.TextChoices):
|
|
DRAFT = "draft", "Draft"
|
|
GENERATING = "generating", "Generating"
|
|
READY = "ready", "Ready"
|
|
FAILED = "failed", "Failed"
|
|
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="client_sites")
|
|
template_option = models.ForeignKey(TemplateOption, on_delete=models.PROTECT, related_name="client_sites")
|
|
business_name = models.CharField(max_length=160)
|
|
business_address = models.CharField(max_length=255)
|
|
business_phone = models.CharField(max_length=40)
|
|
business_description = models.TextField()
|
|
old_website = models.URLField(blank=True)
|
|
status = models.CharField(max_length=20, choices=Status.choices, default=Status.DRAFT)
|
|
ai_payload = models.JSONField(default=dict, blank=True)
|
|
basic_zip_path = models.CharField(max_length=255, blank=True)
|
|
django_zip_path = models.CharField(max_length=255, blank=True)
|
|
last_error = models.TextField(blank=True)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
class Meta:
|
|
ordering = ["-created_at"]
|
|
|
|
def __str__(self) -> str:
|
|
return f"{self.business_name} ({self.owner})"
|