from django.db import models

# Create your models here.

class User(models.Model):
    NAME                = models.CharField(max_length=255,blank=True, null=True)
    MOBILE_NO           = models.BigIntegerField()
    EMAIL_ID            = models.EmailField()
    PASSWORD            = models.CharField(max_length=255,blank=True, null=True)
    CONFIRM_PASSWORD    = models.CharField(max_length=255,blank=True, null=True)
    DOB                 = models.DateField(blank=True, null=True)
    ADDRESS_1           = models.CharField(max_length=255,blank=True, null=True)
    ADDRESS_2           = models.CharField(max_length=255, blank=True, null=True)
    IS_DELETED          = models.BooleanField(default=False)
    CREATED_AT          = models.DateTimeField(auto_now_add=True)
    UPDATED_AT          = models.DateTimeField(auto_now=True)

    class meta:
        db_table="user"
   

class LoginLog(models.Model):
    USER            = models.ForeignKey("User",on_delete=models.CASCADE,verbose_name="User")
    LOGIN_DATETIME  = models.DateTimeField(null=True,blank=True)
    LOGOUT_DATETIME = models.DateTimeField(null=True,blank=True)
    LOGIN_SESSION   = models.TextField(blank=True,null=True)
    IP_ADDRESS      = models.CharField(max_length=16,blank=True,null=True)
    LOGIN_STATUS    = models.BooleanField(default=True)

    class meta:
        db_table="login_log"

class ProductMaterial(models.Model):
    MATERIAL_NAME   = models.CharField(max_length=100,blank=True, null=True)
    IS_DELETED      = models.BooleanField(default=False)
    CREATED_AT      = models.DateTimeField(auto_now_add=True)
    UPDATED_AT      = models.DateTimeField(auto_now=True)

    class meta:
        db_table="product_material"

class CigarProduct(models.Model):
    PRODUCT_NAME   = models.CharField(max_length=255,blank=True, null=True)
    PRICE          = models.FloatField()
    DISCOUNT       = models.FloatField()
    IS_AVAILABLE   = models.BooleanField(default=True)
    SHIPPING_FEE   = models.FloatField()
    IS_DELETED     = models.BooleanField(default=False)
    CREATED_AT     = models.DateTimeField(auto_now_add=True)
    UPDATED_AT     = models.DateTimeField(auto_now=True)

    class Meta:
        db_table="cigar_product"


class UserCustomization(models.Model):
    USER=models.ForeignKey("User",on_delete=models.CASCADE,verbose_name="User")
    PRODUCT=models.ForeignKey("CigarProduct",on_delete=models.CASCADE,verbose_name="User")
    MATERIAL=models.ForeignKey("ProductMaterial",on_delete=models.CASCADE,verbose_name="User")
    TEXT=models.CharField(max_length=100,blank=True, null=True)
    DESCRIPTION=models.TextField()
    IS_DELETED=models.BooleanField(default=False)
    CREATED_AT = models.DateTimeField(auto_now_add=True)
    UPDATED_AT = models.DateTimeField(auto_now=True)

    class Meta:
        db_table='user_customization'

class Product_Image(models.Model):
    PRODUCT      = models.ForeignKey("CigarProduct",on_delete=models.CASCADE,verbose_name="CigarProduct")
    FULL_IMAGE   = models.FileField(upload_to='files/') 
    SUB_IMAGE_1  = models.FileField(upload_to='files/') 
    SUB_IMAGE_2  = models.FileField(upload_to='files/')
    SUB_IMAGE_3  = models.FileField(upload_to='files/')
    SUB_IMAGE_4  = models.FileField(upload_to='files/')
    IS_DELETED   = models.BooleanField(default=False)
    CREATED_AT   = models.DateTimeField(auto_now_add=True)
    UPDATED_AT   = models.DateTimeField(auto_now=True)

    class Meta:
        db_table='product_image'