from django.db import models

# Create your models here.
from django.db import models
from django.contrib.auth import get_user_model

class Morador(models.Model):
    UNIDADE_CHOICES = [
        ('apartamento', 'Apartamento'),
        ('casa', 'Casa'),
        ('lote', 'Lote'),
    ]

    VINCULO_CHOICES = [
        ('proprietario', 'Proprietário'),
        ('locatario', 'Locatário'),
    ]

    user = models.OneToOneField(get_user_model(), on_delete=models.CASCADE, related_name='morador')
    nome_completo = models.CharField(max_length=255)
    telefone = models.CharField(max_length=20, blank=True, null=True)

    tipo_unidade = models.CharField(max_length=20, choices=UNIDADE_CHOICES)
    identificacao_unidade = models.CharField(max_length=50, help_text="Ex: Apto 101, Casa 12, Lote B")

    vinculo = models.CharField(max_length=20, choices=VINCULO_CHOICES)
    em_aluguel = models.BooleanField(default=False, help_text="A unidade está atualmente alugada?")
    aluguel_por_app = models.BooleanField(default=False, help_text="É alugada por app como Airbnb?")

    data_cadastro = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return f"{self.nome_completo} - {self.identificacao_unidade}"
