from django.db import models
import ulid
from XCMS_PIM.models import WorkspaceUser
from django.db.models.constraints import UniqueConstraint
from django.forms.models import model_to_dict
from app.models.product_classification_model import ProductClassificationModel
from app.models.channel_model import ChannelModel
from XCMS_PIM.pim_cnsts import *


class ULIDField(models.CharField):
    def __init__(self, *args, **kwargs):
        kwargs["max_length"] = 26
        super(ULIDField, self).__init__(*args, **kwargs)

    def db_type(self, connection):
        return "char(26)"


class ChannelImageOutputModel(models.Model):
    channel = models.ForeignKey(
        ChannelModel,
        null=False,
        blank=False,
        on_delete=models.DO_NOTHING,
        db_column="channel_cd",
    )
    product_classification = models.ForeignKey(
        ProductClassificationModel,
        null=False,
        blank=False,
        on_delete=models.DO_NOTHING,
        db_column="product_classification_cd",
    )
    asset_item_id = models.CharField(max_length=50)
    asset_item_type = models.CharField(max_length=1)

    class Meta:
        managed = False
        db_table = "output_channels_image_t"
