Add a complete contact form system with the following changes: - Create ContactMessage model to store form submissions with tracking fields (is_read, is_responded) - Implement ContactMessage admin interface with custom actions, filters, and bulk operations - Add contact endpoint documentation to API root view - Update email configuration to use admin@attunehearttherapy.com as sender address This enables users to submit contact inquiries and allows administrators to track and manage these messages efficiently through the Django admin panel.
59 lines
2.3 KiB
Python
59 lines
2.3 KiB
Python
from django.contrib.auth.models import PermissionsMixin, AbstractBaseUser
|
|
from django.db import models
|
|
from .managers import CustomUserManager
|
|
|
|
class CustomUser(AbstractBaseUser, PermissionsMixin):
|
|
email = models.EmailField(unique=True)
|
|
first_name = models.CharField(max_length=50)
|
|
last_name = models.CharField(max_length=50)
|
|
is_staff = models.BooleanField(default=False)
|
|
is_superuser = models.BooleanField(default=False)
|
|
is_active = models.BooleanField(default=True)
|
|
isVerified = models.BooleanField(default=False)
|
|
verify_otp = models.CharField(max_length=6, blank=True, null=True)
|
|
verify_otp_expiry = models.DateTimeField(null=True, blank=True)
|
|
forgot_password_otp = models.CharField(max_length=6, blank=True, null=True)
|
|
forgot_password_otp_expiry = models.DateTimeField(null=True, blank=True)
|
|
phone_number = models.CharField(max_length=20, blank=True)
|
|
last_login = models.DateTimeField(auto_now=True)
|
|
date_joined = models.DateTimeField(auto_now_add=True)
|
|
|
|
objects = CustomUserManager()
|
|
|
|
USERNAME_FIELD = 'email'
|
|
REQUIRED_FIELDS = ['first_name', 'last_name']
|
|
|
|
def __str__(self):
|
|
return self.email
|
|
|
|
def get_full_name(self):
|
|
return f"{self.first_name} {self.last_name}"
|
|
|
|
class UserProfile(models.Model):
|
|
user = models.OneToOneField(CustomUser, on_delete=models.CASCADE, related_name='profile')
|
|
bio = models.TextField(max_length=500, blank=True)
|
|
timezone = models.CharField(max_length=50, default='UTC')
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
def __str__(self):
|
|
return f"{self.user.email} Profile"
|
|
|
|
|
|
class ContactMessage(models.Model):
|
|
name = models.CharField(max_length=255)
|
|
email = models.EmailField()
|
|
phone = models.CharField(max_length=20, blank=True)
|
|
message = models.TextField()
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
is_read = models.BooleanField(default=False)
|
|
is_responded = models.BooleanField(default=False)
|
|
|
|
class Meta:
|
|
ordering = ['-created_at']
|
|
verbose_name = 'Contact Message'
|
|
verbose_name_plural = 'Contact Messages'
|
|
|
|
def __str__(self):
|
|
return f"{self.name} - {self.email} - {self.created_at.strftime('%Y-%m-%d')}"
|