from django.db import models

# Create your models here.
class NomenclatureBaseModel(models.Model):
    name = models.CharField(max_length=100, unique=True)
    short_name = models.CharField(max_length=5, null=True, blank=True)
    description = models.TextField(blank=True, null=True)
    active = models.BooleanField(default=True)
    class Meta:
        abstract = True
        ordering = ['name']

    def __str__(self):
        return self.name


class CompanyModel(NomenclatureBaseModel):
    ...


class LinesModel(NomenclatureBaseModel):
    company = models.ForeignKey(
        'common.CompanyModel',
        on_delete=models.CASCADE,
        related_name='line_company'
    )

class OperationModel(NomenclatureBaseModel):
    ...

class ContainerKindModel(NomenclatureBaseModel):
    ...

class ContainerTypeModel(models.Model):
    name = models.CharField(max_length=6, unique=True)
    length = models.IntegerField()
    height = models.BooleanField()
    container_type = models.ForeignKey(
        'common.ContainerKindModel',
        on_delete=models.CASCADE,
        related_name='container_type_container_kinds'
    )
    deleted = models.BooleanField(default=False)

    def __str__(self):
        return self.name