from __future__ import annotations from django.db import models from django.conf import settings from orgs.models import Organization class Lead(models.Model): class LeadSource(models.TextChoices): CONTACT = "contact", "Contact" PICKUP_REQUEST = "pickup_request", "Pickup Request" LISTING_REQUEST = "listing_request", "Listing Request" OTHER = "other", "Other" organization = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name="leads") name = models.CharField(max_length=255) email = models.EmailField(blank=True) phone = models.CharField(max_length=64, blank=True) subject = models.CharField(max_length=255, blank=True) message = models.TextField(blank=True) source = models.CharField(max_length=64, blank=True, choices=LeadSource.choices) created_at = models.DateTimeField(auto_now_add=True) created_by = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True, blank=True, related_name="leads_created", ) def __str__(self) -> str: # pragma: no cover return f"Lead {self.name} ({self.organization.code})"