43 lines
1.8 KiB
Python
43 lines
1.8 KiB
Python
from django.core.validators import RegexValidator
|
|
from django.db import models
|
|
|
|
|
|
class ConsultationRequest(models.Model):
|
|
class Subject(models.TextChoices):
|
|
PHYSICS = "physics", "Физика"
|
|
MATHEMATICS = "mathematics", "Математика"
|
|
|
|
class Exam(models.TextChoices):
|
|
OGE = "oge", "ОГЭ"
|
|
EGE = "ege", "ЕГЭ"
|
|
OTHER = "other", "Другая консультация"
|
|
|
|
name = models.CharField("Имя ученика", max_length=100)
|
|
phone = models.CharField(
|
|
"Телефон",
|
|
max_length=30,
|
|
validators=[
|
|
RegexValidator(
|
|
regex=r"^[0-9+()\-\s]{7,30}$",
|
|
message="Введите телефон в привычном формате.",
|
|
)
|
|
],
|
|
)
|
|
contact = models.CharField("Telegram или другой способ связи", max_length=100, blank=True)
|
|
subject = models.CharField("Предмет", max_length=20, choices=Subject.choices)
|
|
exam = models.CharField("Цель подготовки", max_length=20, choices=Exam.choices)
|
|
preferred_date = models.DateField("Желаемая дата")
|
|
preferred_time = models.TimeField("Желаемое время")
|
|
comment = models.TextField("Комментарий", max_length=1000, blank=True)
|
|
created_at = models.DateTimeField("Создана", auto_now_add=True)
|
|
is_processed = models.BooleanField("Заявка обработана", default=False)
|
|
|
|
class Meta:
|
|
verbose_name = "Заявка на консультацию"
|
|
verbose_name_plural = "Заявки на консультации"
|
|
ordering = ("is_processed", "preferred_date", "preferred_time")
|
|
|
|
def __str__(self):
|
|
return f"{self.name}: {self.get_subject_display()} — {self.preferred_date:%d.%m.%Y}"
|
|
|