diff options
-rw-r--r-- | models.py | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -1,4 +1,5 @@ from django.db import models +from django.db.models import Q from django.utils.text import slugify @@ -67,7 +68,14 @@ class Room(models.Model): verbose_name_plural = "salles" +class CourseManager(models.Manager): + def get_courses_for_group(self, group, **filters): + return self.get_queryset().filter(Q(groups__td__isnull=True) | Q(groups__td=group.td), Q(groups__tp__isnull=True) | Q(groups__tp=group.tp), groups__mention=group.mention, groups__subgroup=group.subgroup, **filters).order_by("begin") + + class Course(models.Model): + objects = CourseManager() + name = models.CharField(max_length=255, verbose_name="nom", null=True) type_ = models.CharField(name="type", max_length=255, verbose_name="type de cours", null=True) timetable = models.ForeignKey(Timetable, on_delete=models.CASCADE, verbose_name="emploi du temps") |