from django.db import models
from api.property_api.property.models.property import Property
from common.models.base import TimeStampedModel

class ContactInformation(TimeStampedModel):
    property = models.ForeignKey(
        Property,
        on_delete=models.CASCADE,
        related_name='contact_information'
    )
    first_name = models.CharField(max_length=100)    
    last_name = models.CharField(max_length=100)
    contact = models.CharField(max_length=15)
    message = models.TextField()
    email = models.EmailField()
    district = models.CharField(max_length=50)    

    class Meta:
        ordering = ['first_name']
        verbose_name_plural = "ContactsInfo"
    
    def __str__(self):
        return self.first_name
    
    def soft_delete(self):
        if self.is_active:
            self.is_active = False
            self.save(update_fields=['is_active'])