from django.db import models from django.utils.translation import gettext_lazy as _ class Client(models.Model): name = models.CharField(_("Name"), max_length=200) email = models.EmailField(_("Email"), max_length=254, unique=True) phone = models.CharField(_("Phone"), max_length=20, blank=True, null=True) address = models.TextField(_("Address"), blank=True, null=True) created_at = models.DateTimeField(auto_now_add=True) def __str__(self): return self.name class Case(models.Model): class CaseStatus(models.TextChoices): OPEN = 'OPEN', _('Open') CLOSED = 'CLOSED', _('Closed') PENDING = 'PENDING', _('Pending') case_title = models.CharField(_("Case Title"), max_length=200) case_number = models.CharField(_("Case Number"), max_length=50, unique=True) client = models.ForeignKey(Client, on_delete=models.CASCADE, related_name='cases') status = models.CharField( _("Status"), max_length=10, choices=CaseStatus.choices, default=CaseStatus.OPEN, ) description = models.TextField(_("Description")) created_at = models.DateTimeField(auto_now_add=True) def __str__(self): return f"{self.case_number}: {self.case_title}"