1
from django.db import models
4
class Category(models.Model):
5
name = models.CharField(max_length=64, verbose_name='Категория')
14
class Type(models.Model):
15
name = models.CharField(max_length=64, verbose_name='Тип')
24
class SubType(models.Model):
25
name = models.CharField(max_length=64, verbose_name='Подтип')
26
type = models.ForeignKey(Type, on_delete=models.CASCADE, related_name='subtypes', verbose_name='Тип')
35
class Answer(models.Model):
36
answer = models.CharField(max_length=64, verbose_name='Ответ')
37
subtype = models.ForeignKey(SubType, on_delete=models.CASCADE, verbose_name='Подтип')
38
is_validated = models.BooleanField(default=False)
41
return f'{self.answer}'
44
class Question(models.Model):
45
category = models.ForeignKey(Category, on_delete=models.CASCADE, verbose_name='Тема вопроса')
46
question = models.CharField(max_length=128, verbose_name='Вопрос')
47
answer = models.ForeignKey(Answer, on_delete=models.CASCADE, verbose_name='Правильный ответ')
48
is_validated = models.BooleanField(default=False, verbose_name='Одобрен')
49
rating = models.IntegerField(default=0, verbose_name='Очки')
50
created_at = models.DateTimeField(auto_now_add=True, verbose_name='Дата создания')
53
ordering = ('-created_at',)
56
return f'{self.question}'
59
class QuestionComplaint(models.Model):
60
question = models.ForeignKey(Question, on_delete=models.CASCADE, verbose_name='Вопрос')
61
text = models.CharField(max_length=128, verbose_name='Жалоба')