feat(contacts): store contact submissions
This commit is contained in:
36
apps/contacts/models.py
Normal file
36
apps/contacts/models.py
Normal file
@@ -0,0 +1,36 @@
|
||||
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}"
|
||||
Reference in New Issue
Block a user