diff --git a/stages/tests.py b/stages/tests.py
index d7ddb0e..07570bf 100644
--- a/stages/tests.py
+++ b/stages/tests.py
@@ -89,6 +89,15 @@ class StagesTest(TestCase):
response3 = self.client.get(reverse('stages_export'), {'period': '1', 'non_attr': '1'})
self.assertEqual(response2.status_code, 200)
+ def test_attribution_view(self):
+ response = self.client.get(reverse('attribution'))
+ # Section select
+ self.assertContains(response,
+ '' % Section.objects.get(name='ASE').pk)
+ # Referent select
+ self.assertContains(response,
+ '' % Teacher.objects.get(abrev="JCA").pk)
+
def test_new_training(self):
student = Student.objects.get(last_name='Varrin')
avail = Availability.objects.get(pk=2)
diff --git a/stages/views.py b/stages/views.py
index 082023e..f450d3b 100644
--- a/stages/views.py
+++ b/stages/views.py
@@ -152,7 +152,7 @@ class AttributionView(TemplateView):
# 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(archived=False, training__availability__period__end_date__gte=school_year_start()
+ for ref in Teacher.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)