aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin2017-09-07 12:22:37 +0200
committerAlban Gruin2017-09-07 12:22:37 +0200
commit7e0f6810963bf272a1ff7e97061577ddc92fa19d (patch)
tree8859fdc272c102e08e21631b450a908202a6202d
parent3907db7917138bbd6ba30fd1c7a13aaa38c8c5e5 (diff)
Application du même traitement aux filtres des cours qu’à l’enregistrement.
À sérieusement besoin d’être nettoyé
-rw-r--r--models.py9
1 files changed, 9 insertions, 0 deletions
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")