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

from apps.shared.models import AbstractBaseModel


class Geology(AbstractBaseModel):
    category = models.ForeignKey(
        "Category",
        on_delete=models.CASCADE,
        related_name="cultures",
        verbose_name=_("Kategoriya"),
    )
    banner_title = models.CharField(
        max_length=255, verbose_name=_("Banner sarlavhasi"), null=True, blank=True
    )
    banner = models.ImageField(
        upload_to="banners/", verbose_name=_("Banner"), null=True, blank=True
    )
    name = models.CharField(max_length=255, verbose_name=_("Тог жинси номи"))
    title = models.CharField(max_length=255, verbose_name=_("Тог жинсининг геологик раками"))
    body1 = models.TextField(verbose_name=_("Тог жинсининг макроскопик таснифи"), null=True, blank=True)
    address = models.CharField(max_length=255, verbose_name=_("Олинган жойи"), null=True, blank=True)
    image = models.ImageField(upload_to="images/", verbose_name=_("Олинган жойи сурати"), null=True, blank=True)
    location = models.CharField(max_length=255, verbose_name=_("Кординаталар"), null=True, blank=True)
    composition = models.TextField(verbose_name=_("Тог жинсининг кимёвий таркиби (%)"), null=True, blank=True)
    isp = models.TextField(verbose_name=_("Тоғ жинсининг ISP - масс-спектрометрик тахлил натижаси (г/т)"), null=True,
                           blank=True)
    analysis = models.TextField(
        verbose_name=_("Тоғ жинсининг спектрал тахлил натижаси (%)"), null=True, blank=True
    )
    body2 = models.TextField(verbose_name=_("Тоғ жинсининг шаффоф шлифда кўриниши"), null=True, blank=True)
    photos1 = models.ManyToManyField(
        "Photo", verbose_name=_("Барча кўрнишлар"), related_name="geology_photos1", blank=True
    )
    body3 = models.TextField(verbose_name=_("Тоғ жинсининг аншлифда кўриниши"), null=True, blank=True)
    photos2 = models.ManyToManyField(
        "Photo", verbose_name=_("Барча кўрнишлар"), related_name="geology_photos2", blank=True
    )

    class Meta:
        verbose_name = _("Madan")
        verbose_name_plural = _("Madanlar")
        ordering = ["-created_at"]

    def __str__(self) -> str:
        return self.name
