From 57f191675871a2e58e98ce7e1664e3a0a94099f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Schweigh=C3=B6fer?= Date: Thu, 21 Jun 2018 11:53:56 +0200 Subject: [PATCH] Kinda fixes #55 --- pyBuchaktion/admin.py | 1 + pyBuchaktion/models.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/pyBuchaktion/admin.py b/pyBuchaktion/admin.py index c4d36ad..41286bd 100644 --- a/pyBuchaktion/admin.py +++ b/pyBuchaktion/admin.py @@ -449,6 +449,7 @@ class OrderTimeframeAdmin(ModelAdmin): 'end_date', 'start_date', 'semester', + 'student_count', ) form = OrderTimeframeForm diff --git a/pyBuchaktion/models.py b/pyBuchaktion/models.py index 20e5111..f3f127f 100644 --- a/pyBuchaktion/models.py +++ b/pyBuchaktion/models.py @@ -403,6 +403,9 @@ def __str__(self): def natural_key(self): return { "from": self.start_date, "to": self.end_date } + def student_count(self): + return self.order_set.values('student').distinct().count() + # Set the singular and plural names for i18n class Meta: verbose_name = _("order timeframe")