from ctypes.wintypes import CHAR
from distutils.command.upload import upload
from random import choice
from telnetlib import STATUS
from unicodedata import category
from django.db import models
from ckeditor.fields import RichTextField
from taggit.managers import TaggableManager

# Create your models here.
from mptt.models import MPTTModel, TreeForeignKey

class Category(MPTTModel):
    name = models.CharField(max_length=50, unique=True)
    parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True, blank=True, related_name='children')
    is_active = models.BooleanField(default=True)
    created_at  = models.DateTimeField(auto_now_add=True)
    updated_at  = models.DateTimeField(auto_now=True)

    class MPTTMeta:
        order_insertion_by = ['name']

class Brand(models.Model):
    name = models.CharField(max_length=50)
    is_active = models.BooleanField(default=True)
    created_at  = models.DateTimeField(auto_now_add=True)
    updated_at  = models.DateTimeField(auto_now=True)


class Product(models.Model):
    STATUS_CHOICES = (
        ('NONE', 'NONE'),
        ('NEW', 'NEW'),
        ('SALE', 'SALE'),
        ('HOT', 'HOT'),
    )
    title = models.CharField(max_length=50)
    price = models.DecimalField(max_digits=5, decimal_places=2)
    short_description = RichTextField()
    tags = TaggableManager()
    description = RichTextField()
    specification = RichTextField()
    image = models.ImageField(upload_to='product/')
    category = models.ForeignKey(Category, on_delete=models.CASCADE)
    brand = models.ForeignKey(Brand, on_delete=models.CASCADE)
    stack = models.IntegerField(default=5)
    status = models.CharField(max_length=5, choices=STATUS_CHOICES, default='NONE')
    is_fetured  = models.BooleanField(default=False)
    is_special  = models.BooleanField(default=False)
    is_active = models.BooleanField(default=True)
    created_at  = models.DateTimeField(auto_now_add=True)
    updated_at  = models.DateTimeField(auto_now=True)

class ProductImages(models.Model):
    category = models.ForeignKey(Product, on_delete=models.CASCADE, related_name='images')
    image = models.ImageField(upload_to='products/')
[((14, 11, 14, 55), 'django.db.models.CharField', 'models.CharField', (), '', False, 'from django.db import models\n'), ((15, 13, 15, 109), 'mptt.models.TreeForeignKey', 'TreeForeignKey', (), '', False, 'from mptt.models import MPTTModel, TreeForeignKey\n'), ((16, 16, 16, 49), 'django.db.models.BooleanField', 'models.BooleanField', (), '', False, 'from django.db import models\n'), ((17, 18, 17, 57), 'django.db.models.DateTimeField', 'models.DateTimeField', (), '', False, 'from django.db import models\n'), ((18, 18, 18, 53), 'django.db.models.DateTimeField', 'models.DateTimeField', (), '', False, 'from django.db import models\n'), ((24, 11, 24, 42), 'django.db.models.CharField', 'models.CharField', (), '', False, 'from django.db import models\n'), ((25, 16, 25, 49), 'django.db.models.BooleanField', 'models.BooleanField', (), '', False, 'from django.db import models\n'), ((26, 18, 26, 57), 'django.db.models.DateTimeField', 'models.DateTimeField', (), '', False, 'from django.db import models\n'), ((27, 18, 27, 53), 'django.db.models.DateTimeField', 'models.DateTimeField', (), '', False, 'from django.db import models\n'), ((37, 12, 37, 43), 'django.db.models.CharField', 'models.CharField', (), '', False, 'from django.db import models\n'), ((38, 12, 38, 63), 'django.db.models.DecimalField', 'models.DecimalField', (), '', False, 'from django.db import models\n'), ((39, 24, 39, 39), 'ckeditor.fields.RichTextField', 'RichTextField', ({}, {}), '()', False, 'from ckeditor.fields import RichTextField\n'), ((40, 11, 40, 28), 'taggit.managers.TaggableManager', 'TaggableManager', ({}, {}), '()', False, 'from taggit.managers import TaggableManager\n'), ((41, 18, 41, 33), 'ckeditor.fields.RichTextField', 'RichTextField', ({}, {}), '()', False, 'from ckeditor.fields import RichTextField\n'), ((42, 20, 42, 35), 'ckeditor.fields.RichTextField', 'RichTextField', ({}, {}), '()', False, 'from ckeditor.fields import RichTextField\n'), ((43, 12, 43, 51), 'django.db.models.ImageField', 'models.ImageField', (), '', False, 'from django.db import models\n'), ((44, 15, 44, 68), 'django.db.models.ForeignKey', 'models.ForeignKey', (), '', False, 'from django.db import models\n'), ((45, 12, 45, 62), 'django.db.models.ForeignKey', 'models.ForeignKey', (), '', False, 'from django.db import models\n'), ((46, 12, 46, 42), 'django.db.models.IntegerField', 'models.IntegerField', (), '', False, 'from django.db import models\n'), ((47, 13, 47, 83), 'django.db.models.CharField', 'models.CharField', (), '', False, 'from django.db import models\n'), ((48, 18, 48, 52), 'django.db.models.BooleanField', 'models.BooleanField', (), '', False, 'from django.db import models\n'), ((49, 18, 49, 52), 'django.db.models.BooleanField', 'models.BooleanField', (), '', False, 'from django.db import models\n'), ((50, 16, 50, 49), 'django.db.models.BooleanField', 'models.BooleanField', (), '', False, 'from django.db import models\n'), ((51, 18, 51, 57), 'django.db.models.DateTimeField', 'models.DateTimeField', (), '', False, 'from django.db import models\n'), ((52, 18, 52, 53), 'django.db.models.DateTimeField', 'models.DateTimeField', (), '', False, 'from django.db import models\n'), ((55, 15, 55, 90), 'django.db.models.ForeignKey', 'models.ForeignKey', (), '', False, 'from django.db import models\n'), ((56, 12, 56, 52), 'django.db.models.ImageField', 'models.ImageField', (), '', False, 'from django.db import models\n')]