From 970148e72bd2bfc846082cdf1644625164664a34 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Tue, 19 Jan 2016 12:16:27 +0100 Subject: [PATCH] Hide archived referentes on attribution view --- stages/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stages/views.py b/stages/views.py index c1bf431..23066c4 100644 --- a/stages/views.py +++ b/stages/views.py @@ -80,11 +80,11 @@ class AttributionView(TemplateView): def get_context_data(self, **kwargs): context = super(AttributionView, self).get_context_data(**kwargs) # Need 2 queries, because referents with no training item would not appear in the second query - referents = Referent.objects.all().order_by('last_name', 'first_name') + referents = Referent.objects.filter(archived=False).order_by('last_name', 'first_name') # Populate each referent with the number of referencies done during the current school year ref_counts = dict([(ref.id, ref.num_refs) - for ref in Referent.objects.filter(training__availability__period__end_date__gte=school_year_start() + for ref in Referent.objects.filter(archived=False, training__availability__period__end_date__gte=school_year_start() ).annotate(num_refs=Count('training'))]) for ref in referents: ref.num_refs = ref_counts.get(ref.id, 0)