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.
34 lines
1.2 KiB
34 lines
1.2 KiB
from django.db import models
|
|
from django.utils import timezone
|
|
|
|
|
|
class Course(models.Model):
|
|
title = models.CharField("Название курса", max_length=100)
|
|
short_description = models.TextField("Краткое описание курса")
|
|
background = models.ImageField("Фон курса", upload_to='courses')
|
|
price = models.DecimalField("Цена курса", help_text="Если цены нету, то курс бесплатный", max_digits=10, decimal_places=2, null=True, blank=True)
|
|
is_highlighted = models.BooleanField(default=False)
|
|
deferred_start = models.DateTimeField("Отложенный запуск курса", help_text="Заполнить если курс отложенный", null=True, blank=True)
|
|
|
|
# created_at
|
|
# update_at
|
|
|
|
# category
|
|
|
|
def is_free(self):
|
|
if self.price:
|
|
return False
|
|
return True
|
|
|
|
def is_deferred_start(self):
|
|
if not self.deferred_start:
|
|
return False
|
|
|
|
if timezone.now() < self.deferred_start:
|
|
return True
|
|
return False
|
|
|
|
class Meta:
|
|
verbose_name = "Курс"
|
|
verbose_name_plural = "Курсы"
|
|
|
|
|