feat: Gestion du planning [3]

This commit is contained in:
Luc SORIGNET
2025-05-03 15:12:17 +02:00
parent cb4fe74a9e
commit 58144ba0d0
39 changed files with 939 additions and 1864 deletions

View File

@ -2,6 +2,7 @@ from django.contrib.auth.models import AbstractUser
from django.db import models
from django.utils.translation import gettext_lazy as _
from django.conf import settings
from School.models import SchoolClass
from Establishment.models import Establishment
@ -14,25 +15,33 @@ class RecursionType(models.IntegerChoices):
class Planning(models.Model):
establishment = models.ForeignKey(Establishment, on_delete=models.PROTECT)
school_class = models.ForeignKey(
SchoolClass,
on_delete=models.CASCADE,
related_name="planning",
null=True, # Permet des valeurs nulles
blank=True # Rend le champ facultatif dans les formulaires
)
name = models.CharField(max_length=255)
description = models.TextField(default="", blank=True, null=True)
color= models.CharField(max_length=255, default="#000000")
def __str__(self):
return f'Planning for {self.user.username}'
return f'Planning {self.name}'
class Events(models.Model):
planning = models.ForeignKey(Planning, on_delete=models.PROTECT)
planning = models.ForeignKey(Planning, on_delete=models.CASCADE)
title = models.CharField(max_length=255)
description = models.TextField()
description = models.TextField(default="", blank=True, null=True)
start = models.DateTimeField()
end = models.DateTimeField()
recursionType = models.IntegerField(choices=RecursionType, default=0)
recursionEnd = models.DateTimeField(default=None, blank=True, null=True)
color= models.CharField(max_length=255)
location = models.CharField(max_length=255, default="", blank=True, null=True)
created_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return f'Event for {self.user.username}'
return f'Event {self.title}'