diff options
Diffstat (limited to 'models.py')
-rw-r--r-- | models.py | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -39,15 +39,16 @@ class Year(models.Model): class Timetable(models.Model): year = models.ForeignKey(Year, verbose_name="année") - name = models.CharField(max_length=64, unique=True, verbose_name="nom") - url = models.URLField(max_length=255, unique=True, verbose_name="URL") - slug = models.SlugField(max_length=64, unique=True, default="") + name = models.CharField(max_length=64, verbose_name="nom") + url = models.URLField(max_length=255, verbose_name="URL") + slug = models.SlugField(max_length=64, default="") def __str__(self): return self.year.name + " " + self.name class Meta: + unique_together = (("year", "name"), ("year", "slug"),) verbose_name = "emploi du temps" verbose_name_plural = "emplois du temps" @@ -71,8 +72,8 @@ class LastUpdate(models.Model): class GroupManager(Manager): - def get_relevant_groups(self, *args, **filters): - return self.get_queryset().filter(*args, **filters).annotate(children_count=Count("children")).filter(children_count=0) + def get_relevant_groups(self, *args, **criteria): + return self.get_queryset().filter(*args, **criteria).annotate(children_count=Count("children")).filter(children_count=0) class Group(models.Model): @@ -151,8 +152,8 @@ class Room(models.Model): class CourseManager(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), Q(groups__subgroup__isnull=True) | Q(groups__subgroup=group.subgroup), groups__mention=group.mention, timetable=group.timetable, **filters).order_by("begin") + def get_courses_for_group(self, group, **criteria): + 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), Q(groups__subgroup__isnull=True) | Q(groups__subgroup=group.subgroup), groups__mention=group.mention, timetable=group.timetable, **criteria).order_by("begin") def get_weeks(self, **criteria): return self.get_queryset().filter(**criteria).order_by("groups__name", "year", "week").annotate(_=Count(("groups", "year", "week", "begin")), year=ExtractYear("begin"), week=ExtractWeek("begin")) |