Display student age at period start on attributions view

This commit is contained in:
Claude Paroz 2016-01-15 18:17:35 +01:00
parent 473493542c
commit 894cc172a8
4 changed files with 27 additions and 10 deletions

View file

@ -102,6 +102,14 @@ class StudentSummaryView(DetailView):
context = super(StudentSummaryView, self).get_context_data(**kwargs)
context['previous_stages'] = self.object.training_set.all(
).select_related('availability__corporation').order_by('availability__period__end_date')
period_id = self.request.GET.get('period')
if period_id:
try:
period = Period.objects.get(pk=int(period_id))
except Period.DoesNotExist:
pass
else:
context['age_for_stage'] = self.object.age_at(period.start_date)
return context