37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
from django.db import models
|
|
|
|
from core.models.base import BaseModel
|
|
|
|
|
|
class ContactSubmission(BaseModel):
|
|
class Status(models.TextChoices):
|
|
NEW = "new", "New"
|
|
CONTACTED = "contacted", "Contacted"
|
|
CLOSED = "closed", "Closed"
|
|
SPAM = "spam", "Spam"
|
|
|
|
first_name = models.CharField(max_length=120)
|
|
last_name = models.CharField(max_length=120)
|
|
email = models.EmailField()
|
|
mobile = models.CharField(max_length=32)
|
|
message = models.TextField()
|
|
status = models.CharField(
|
|
max_length=20,
|
|
choices=Status.choices,
|
|
default=Status.NEW,
|
|
)
|
|
ip_address = models.GenericIPAddressField(null=True, blank=True)
|
|
user_agent = models.TextField(blank=True)
|
|
|
|
class Meta:
|
|
db_table = "contact_submission"
|
|
ordering = ("-created_at",)
|
|
indexes = (
|
|
models.Index(fields=("created_at",), name="contact_created_at_idx"),
|
|
models.Index(fields=("status",), name="contact_status_idx"),
|
|
models.Index(fields=("email",), name="contact_email_idx"),
|
|
)
|
|
|
|
def __str__(self):
|
|
return f"{self.first_name} {self.last_name} - {self.email}"
|