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

class PropertyDetails(TimeStampedModel):
    key = models.CharField(max_length=15)
    property_id = models.ForeignKey(Property, on_delete=models.CASCADE, related_name='property')
    value = models.CharField(max_length=15)
    icon_url = models.ImageField(upload_to="property_details")

    class Meta:
        ordering = ['property_id']
        verbose_name_plural = "Property_details"
    
    def soft_delete(self):
        if self.is_active:
            self.is_active = False
            self.save(update_fields=['is_active'])