diff options
author | Alban Gruin | 2017-09-07 12:22:37 +0200 |
---|---|---|
committer | Alban Gruin | 2017-09-07 12:22:37 +0200 |
commit | 7e0f6810963bf272a1ff7e97061577ddc92fa19d (patch) | |
tree | 8859fdc272c102e08e21631b450a908202a6202d /models.py | |
parent | 3907db7917138bbd6ba30fd1c7a13aaa38c8c5e5 (diff) |
Application du même traitement aux filtres des cours qu’à l’enregistrement.
À sérieusement besoin d’être nettoyé
Diffstat (limited to 'models.py')
-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") |