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

class MediaType(models.IntegerChoices):
    Interior = 1
    Map = 2
    Exterior = 3
    Video = 4

class PropertyMedia(TimeStampedModel):
    property_ID = models.ForeignKey(Property, on_delete=models.CASCADE, related_name='media')
    media_url = models.ImageField(upload_to="property_media")
    media_type = models.IntegerField(choices=MediaType)
    is_featured = models.BooleanField()

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