Add class listings with training summary
This commit is contained in:
parent
6c9ab66ae7
commit
538db63679
6 changed files with 78 additions and 2 deletions
|
|
@ -245,6 +245,7 @@ class Training(models.Model):
|
|||
|
||||
class Meta:
|
||||
verbose_name = "Stage"
|
||||
ordering = ("-availability__period",)
|
||||
|
||||
def __str__(self):
|
||||
return '%s chez %s (%s)' % (self.student, self.availability.corporation, self.availability.period)
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@ from tabimport import FileFactory
|
|||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db.models import Count
|
||||
from django.db.models import Case, Count, When
|
||||
from django.http import HttpResponse, HttpResponseNotAllowed, HttpResponseRedirect
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.views.generic import DetailView, FormView, TemplateView, ListView
|
||||
|
||||
from .forms import PeriodForm, StudentImportForm
|
||||
from .models import (Section, Student, Corporation, CorpContact, Period,
|
||||
from .models import (Klass, Section, Student, Corporation, CorpContact, Period,
|
||||
Training, Referent, Availability)
|
||||
|
||||
|
||||
|
|
@ -62,6 +62,24 @@ class CorporationView(DetailView):
|
|||
return context
|
||||
|
||||
|
||||
class KlassListView(ListView):
|
||||
queryset = Klass.objects.all().annotate(num_students=Count(Case(When(student__archived=False, then=1)))
|
||||
).filter(num_students__gt=0).order_by('section', 'name')
|
||||
template_name = 'classes.html'
|
||||
|
||||
|
||||
class KlassView(DetailView):
|
||||
model = Klass
|
||||
template_name = 'class.html'
|
||||
context_object_name = 'klass'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['students'] = self.object.student_set.filter(archived=False
|
||||
).prefetch_related('training_set').order_by('last_name', 'first_name')
|
||||
return context
|
||||
|
||||
|
||||
class AttributionView(TemplateView):
|
||||
"""
|
||||
Base view for the attribution screen. Populate sections and referents.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue