from django.db import models
import uuid


class Supplier(models.Model):
    """Поставщик - компания, предлагающая товары на бирже"""
    uuid = models.CharField(max_length=100, unique=True, default=uuid.uuid4)
    team_uuid = models.CharField(max_length=100, unique=True)  # Связь с Logto organization

    name = models.CharField(max_length=255)
    description = models.TextField(blank=True, default='')
    country = models.CharField(max_length=100, blank=True, default='')
    country_code = models.CharField(max_length=3, blank=True, default='')
    logo_url = models.URLField(blank=True, default='')

    # Координаты для карты
    latitude = models.FloatField(null=True, blank=True)
    longitude = models.FloatField(null=True, blank=True)

    is_verified = models.BooleanField(default=False)
    is_active = models.BooleanField(default=True)

    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        db_table = 'suppliers'
        ordering = ['name']

    def __str__(self):
        return f"{self.name} ({self.country})"
