from django.db import models
from django.utils.translation import gettext_lazy as _

# from core.app.models import *


class Country(models.Model):
    name = models.CharField(max_length=50, verbose_name=_("Name"))
    # region = models.ForeignKey(( "location.Region"), null=True, on_delete=models.DO_NOTHING)

    # city = models.ForeignKey(( "commons.City"), null=True, on_delete=models.DO_NOTHING)

    def get_cities(self):
        return [city.name for city in self.cities.all()]  # type: ignore

    @staticmethod
    def get_countries_cities_dict():
        countries = Country.objects.all()
        return {country.name: country.get_cities() for country in countries}

    class Meta:
        verbose_name = _("Country")
        verbose_name_plural = _("Countries")
        ordering = ["name"]
        db_table = "Countries"

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


class City(models.Model):
    name = models.CharField(max_length=100, verbose_name=_("Name"))
    country = models.ForeignKey(("Country"), related_name="cities", on_delete=models.CASCADE)

    class Meta:
        verbose_name = _("City")
        verbose_name_plural = _("Cities")
        ordering = ["name"]
        db_table = "Cities"


# class Region(models.Model):
#     name = models.CharField(max_length=100, verbose_name=_("Name"))
#     region = models.CharField(max_length=100, null=True, verbose_name=_("Region"))

#     # location = models.CharField(max_length=100, null=True, verbose_name=_('Location'))
#     # country = models.ForeignKey(('Client.Country'), on_delete=models.CASCADE)
#     # Corporate = models.ForeignKey(('Organisations.Corporate'), on_delete=models.CASCADE)
#     # stock = models.ForeignKey(('Stocks.Stock'), on_delete=models.CASCADE)

#     class Meta:
#         verbose_name = _("Region")
#         verbose_name_plural = _("Regions")
#         ordering = ["name"]
#         db_table = "Regions"

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