from django.db import models
from django.urls import reverse
from django.utils.translation import gettext_lazy as _

class Location(models.Model):
    location_name = models.CharField(
        _('nombre de la ubicación'),
        max_length=200
    )
    slug = models.SlugField(
        _('slug'),
        max_length=200,
        unique=True
    )
    location_state = models.CharField(
        _('departamento / estado'),
        max_length=200
    )
    location_country = models.CharField(
        _('país'),
        max_length=200
    )
    location_description = models.CharField(
        _('descripción'),
        max_length=255
    )
    location_Image = models.ImageField(
        _('imagen de la ubicación'),
        upload_to='photos/locations'
    )
    
    def get_url_compra(self):
        return reverse('properties_by_location_comprar', args=[self.slug])
    
    def get_url_renta(self):
        return reverse('properties_by_location_rentar', args=[self.slug])
    
    def __str__(self):
        return self.location_name

    class Meta:
        verbose_name = _('ubicación')
        verbose_name_plural = _('ubicaciones')
