From bc7cac9459ac3ae55a31e9dd215cfc8f054e5fb1 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Thu, 18 Jan 2018 13:35:29 +0100 Subject: get_courses() émet une exception si l’objet passé n’est ni un groupe ni une salle --- models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/models.py b/models.py index 56c1845..5de1df2 100644 --- a/models.py +++ b/models.py @@ -179,6 +179,8 @@ class CourseManager(Manager): .prefetch_related("rooms") elif isinstance(obj, Room): qs = qs.filter(rooms__in=(obj,), **criteria) + else: + raise(TypeError, "obj must be a Group or a Room") return qs.order_by("begin") -- cgit v1.2.1