diff options
author | Alban Gruin | 2017-01-20 14:37:31 +0100 |
---|---|---|
committer | Alban Gruin | 2017-01-20 14:37:31 +0100 |
commit | 5349208724305c9ec1ea4ab1c51af9969dc586e0 (patch) | |
tree | 94674609b1096093ff3e748dcfe7b0b47c5839f0 /models.py | |
parent | d9ae54412cfee62da29340d9f46a3e797750b883 (diff) |
Changement du gestionnaire des cours
Diffstat (limited to 'models.py')
-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") |