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)