from django.db import models
import uuid
from django.contrib.postgres.fields import ArrayField
from django_quill.fields import QuillField


# Create your models here.
class Projects(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    date_created = models.DateTimeField(null=True, blank=True)
    thumbnail = models.CharField(
        default="https://cdn.caracole.ph/not-found/image-not-found.jpg"
    )
    title = models.CharField(max_length=525)
    images = ArrayField(models.TextField())
    description = QuillField()
    article_copy = QuillField()
    video_title = models.CharField(max_length=255)
    video_type = models.CharField(max_length=255)
    video_link = models.TextField()
    video_description = models.TextField()

    def __str__(self):
        return f"{self.title} - {self.video_type}"

    def save(self, *args, **kwags):
        self.video_type = self.video_type.title()
        self.title = self.title.title()

        super(Projects, self).save(*args, **kwags)


class ProductFocus(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    project = models.ForeignKey(
        Projects, on_delete=models.CASCADE, related_name="project_product_focuses"
    )
    product_image_path = models.TextField()
    collection = models.CharField(max_length=255)
    product_name = models.CharField(max_length=255)
    product_description = models.CharField(max_length=1000)

    def __str__(self):
        return f"{self.product_name} - {self.collection} | {self.project.title}"
