From: Gael Le Mignot Date: Mon, 29 Jul 2019 08:41:35 +0000 (+0200) Subject: Workaround for weird bug due to comparing datetime and date objects X-Git-Tag: 1.4.1~17^2~1^2 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=4ee307cc959a6d52174178b3a7bab552503e9ffd;p=teleforma.git Workaround for weird bug due to comparing datetime and date objects --- diff --git a/teleforma/exam/models.py b/teleforma/exam/models.py index 27a3dd32..c649043a 100755 --- a/teleforma/exam/models.py +++ b/teleforma/exam/models.py @@ -167,7 +167,10 @@ class Quota(models.Model): def script_count(self, statuses): q = self.corrector.corrector_scripts.filter(status__in = statuses) q = q.filter(course=self.course) - q = q.filter(date_submitted__gte=self.date_start).filter(date_submitted__lte=self.date_end) + # Careful, MySQL considers '2019-07-28 11:42:00" to not be >= "2019-07-28" + start = self.date_start + end = self.date_end + datetime.timedelta(days = 1) + q = q.filter(date_submitted__gte=start).filter(date_submitted__lte=end) return q.count()