From 7e0f6810963bf272a1ff7e97061577ddc92fa19d Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Thu, 7 Sep 2017 12:22:37 +0200 Subject: Application du même traitement aux filtres des cours qu’à l’enregistrement. À sérieusement besoin d’être nettoyé --- models.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'models.py') diff --git a/models.py b/models.py index 6296ce1..a75c560 100644 --- a/models.py +++ b/models.py @@ -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") -- cgit v1.2.1