1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-07-05 10:34:09 +02:00

Create phase model to store the calendar

This commit is contained in:
Yohann D'ANELLO
2020-10-20 12:51:03 +02:00
parent 95fd8a066f
commit bbeada74c7
2 changed files with 93 additions and 0 deletions

View File

@ -6,6 +6,7 @@ from django.core.validators import RegexValidator
from django.db import models
from django.db.models import Index
from django.urls import reverse_lazy
from django.utils import timezone
from django.utils.crypto import get_random_string
from django.utils.text import format_lazy
from django.utils.translation import gettext_lazy as _
@ -168,3 +169,34 @@ class Video(models.Model):
class Meta:
verbose_name = _("video")
verbose_name_plural = _("videos")
class Phase(models.Model):
phase_number = models.AutoField(
primary_key=True,
unique=True,
verbose_name=_("phase number"),
)
description = models.CharField(
max_length=255,
verbose_name=_("phase description"),
)
start = models.DateTimeField(
verbose_name=_("start date of the given phase"),
default=timezone.now,
)
end = models.DateTimeField(
verbose_name=_("end date of the given phase"),
default=timezone.now,
)
def __str__(self):
return _("Phase {phase_number:d} starts on {start:%Y-%m-%d %H:%M:} and ends on {end:%Y-%m-%d %H:%M}")\
.format(phase_number=self.phase_number, start=self.start, end=self.end)
class Meta:
verbose_name = _("phase")
verbose_name_plural = _("phases")