from django.db import models
from django_quill.fields import QuillField
from taggit.managers import TaggableManager

from module_iam.models import BaseModel, IAmPrincipal


# Create your models here.
class Organization(BaseModel):
    title = models.CharField(max_length=255)
    contact_us_email = models.EmailField(unique=True, blank=True, null=True)
    instagram_handle = models.URLField(blank=True, null=True)
    facebook_handle = models.URLField(blank=True, null=True)
    linkedin_handle = models.URLField(blank=True, null=True)
    logo_image = models.ImageField(blank=True, null=True, upload_to="organization/logo")
    favicon_image = models.ImageField(
        blank=True, null=True, upload_to="organization/favicon"
    )
    website_url = models.URLField(blank=True, null=True)
    about_us = QuillField()
    terms_condition = QuillField()
    privacy_policy = QuillField()
    subscription_agreement = QuillField()
    license_agreement = QuillField()

    class Meta:
        db_table = "organization"

    def __str__(self):
        return self.title

class FaqCategory(BaseModel):
    name = models.CharField(max_length=255)

    class Meta:
        db_table = "faq_category"

    def __str__(self):
        return self.name


class Faqs(BaseModel):
    faq_category = models.ForeignKey(
        FaqCategory, related_name="faqs_category", blank=True, null=True, on_delete=models.SET_NULL
    )
    question = models.TextField()
    answer = models.TextField()

    class Meta:
        db_table = "faq"

    def __str__(self):
        return self.question
