Açıklama Yok

models.py 1.2KB

1234567891011121314151617181920212223242526272829303132
  1. from __future__ import annotations
  2. from django.db import models
  3. from django.conf import settings
  4. from orgs.models import Organization
  5. class Lead(models.Model):
  6. class LeadSource(models.TextChoices):
  7. CONTACT = "contact", "Contact"
  8. PICKUP_REQUEST = "pickup_request", "Pickup Request"
  9. LISTING_REQUEST = "listing_request", "Listing Request"
  10. OTHER = "other", "Other"
  11. organization = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name="leads")
  12. name = models.CharField(max_length=255)
  13. email = models.EmailField(blank=True)
  14. phone = models.CharField(max_length=64, blank=True)
  15. subject = models.CharField(max_length=255, blank=True)
  16. message = models.TextField(blank=True)
  17. source = models.CharField(max_length=64, blank=True, choices=LeadSource.choices)
  18. created_at = models.DateTimeField(auto_now_add=True)
  19. created_by = models.ForeignKey(
  20. settings.AUTH_USER_MODEL,
  21. on_delete=models.SET_NULL,
  22. null=True,
  23. blank=True,
  24. related_name="leads_created",
  25. )
  26. def __str__(self) -> str: # pragma: no cover
  27. return f"Lead {self.name} ({self.organization.code})"