You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

97 lines
2.8 KiB

from django.db import models
from polymorphic.models import PolymorphicModel
from apps.course.models import Course, Lesson
class ImageObject(models.Model):
image = models.ImageField('Изображение', upload_to='content/imageobject')
created_at = models.DateTimeField(auto_now_add=True)
update_at = models.DateTimeField(auto_now=True)
class Meta:
verbose_name = 'Объект изображения'
verbose_name_plural = 'Объекты изображения'
ordering = ('-created_at',)
class Content(PolymorphicModel):
course = models.ForeignKey(
Course, on_delete=models.CASCADE,
null=True, blank=True,
verbose_name='Курс',
related_name='content',
)
lesson = models.ForeignKey(
Lesson, on_delete=models.CASCADE,
null=True, blank=True,
verbose_name='Урок',
related_name='content',
)
title = models.CharField('Заголовок', max_length=100, default='')
position = models.PositiveSmallIntegerField(
'Положение на странице',
default=1, unique=True
)
created_at = models.DateTimeField(auto_now_add=True)
update_at = models.DateTimeField(auto_now=True)
class Meta:
verbose_name = 'Контент'
verbose_name_plural = 'Контент'
ordering = ('-created_at',)
class Image(Content):
img = models.ImageField('Изображение', upload_to='content/images')
class Text(Content):
txt = models.TextField('Текст', default='')
class ImageText(Content):
img = models.ImageField('Изображение', upload_to='content/images')
txt = models.TextField('Текст', default='')
class Video(Content):
url = models.URLField('Ссылка')
class Gallery(models.Model):
course = models.ForeignKey(
Course, on_delete=models.CASCADE,
null=True, blank=True,
verbose_name='Курс'
)
title = models.CharField('Заголовок', max_length=100, default='')
created_at = models.DateTimeField(auto_now_add=True)
update_at = models.DateTimeField(auto_now=True)
class Meta:
verbose_name = 'Галерея'
verbose_name_plural = 'Галереи'
ordering = ('-created_at',)
class GalleryImage(models.Model):
gallery = models.ForeignKey(
Gallery, on_delete=models.CASCADE,
verbose_name='Галерея'
)
image = models.ImageField(
'Изображение', upload_to='content/gallery_images'
)
created_at = models.DateTimeField(auto_now_add=True)
update_at = models.DateTimeField(auto_now=True)
class Meta:
verbose_name = 'Изображение в галерее'
verbose_name_plural = 'Изображения в галерее'
ordering = ('-created_at',)