from django.db import models
from BaseModels.base_models import BaseModelViewPage, BaseModel
from django.utils.translation import gettext_lazy as _
# from ckeditor.fields import RichTextField
from ckeditor_uploader.fields import RichTextUploadingField
# from colorfield.fields import ColorField
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.fields import GenericRelation
from colorfield.fields import ColorField

class Slide(BaseModel):
    content_type = models.ForeignKey(ContentType, on_delete=models.SET_NULL, null=True)
    object_id = models.PositiveIntegerField()
    content_object = GenericForeignKey('content_type', 'object_id')

    url = models.TextField(verbose_name=_('URL привязанной страницы'), blank=True, null=True)
    title = models.TextField(verbose_name=_('Заголовок'), null=True, blank=True)
    description = RichTextUploadingField(verbose_name=_('Краткое описание'), null=True, blank=True)
    text = RichTextUploadingField(verbose_name=_('Полное описание'), null=True, blank=True, )

    picture = models.ImageField(
        upload_to='uploads/', verbose_name=_('Фоновое изображение'), null=True, blank=True)
    bg_color = ColorField(verbose_name=_('Цвет фона'), default=None, null=True, blank=True)

    but_title = models.CharField(max_length=100, verbose_name=_('Текст на кнопке'), null=True, blank=True)
    but_color = ColorField(verbose_name=_('Цвет кнопки'), default='#000000')

    class Meta:
        verbose_name = _('Слайд')
        verbose_name_plural = _('Слайды')

