from django.contrib.auth import get_user_model
from django.db import models

from tickets.models import Ticket

from dbsynce.docs.database.client import Client as HelpTexts

from core.settings_vars import METASERVICE_ID

class Client(models.Model):
    """
    Client - это таблица с клиентами. Клиент/пользователь/аккаунт 
    в системе, который по логике получает услугу.
    """

    # ID METASERVICE
    id_metaservice = models.PositiveIntegerField(
        default=METASERVICE_ID,
        help_text=HelpTexts.id_metaservice
    )

    # DATA
    requirements = models.CharField(
        max_length=150,
        help_text=HelpTexts.requirements
    )
    status = models.CharField(
        max_length=150,
        help_text=HelpTexts.status
    )

    # OTHER
    is_global = models.CharField(
        max_length=1,
        default=False,
        help_text=HelpTexts.is_global
    )
    is_visible = models.CharField(
        max_length=1,
        default="f",
        help_text=HelpTexts.is_visible
    )

    # FK
    ticket_status = models.ForeignKey(
        Ticket,
        on_delete=models.DO_NOTHING,
        help_text=HelpTexts.ticket_status
    )
    user = models.ForeignKey(
        get_user_model(),
        on_delete=models.DO_NOTHING,
        help_text=HelpTexts.user
    )

    class Meta:
        db_table = "client"
        verbose_name = "Клиента"
        verbose_name_plural = "Клиенты"