diff options
-rw-r--r-- | models.py | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -136,6 +136,15 @@ class Room(models.Model): class CourseManager(Manager): + def filter(self, *args, **filters): + if "type" in filters and filters["type"] is not None: + filters["type"] = filters["type"].replace("COURS", "cours") + filters["type"] = filters["type"].replace("REUNION", "réunion") + if "name" in filters and filters["name"] is not None: + filters["name"] = filters["name"].split("(")[0].strip() + + return super(CourseManager, self).filter(*args, **filters) + 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") |