Do not display archived students in attribution view

This commit is contained in:
Claude Paroz 2013-09-20 15:02:24 +02:00
parent a0bcc21475
commit 8d8454ba56
2 changed files with 6 additions and 5 deletions

View file

@ -15,9 +15,9 @@ class KlassAdmin(admin.ModelAdmin):
class StudentAdmin(admin.ModelAdmin):
list_display = ('__unicode__', 'pcode', 'city', 'klass')
list_display = ('__unicode__', 'pcode', 'city', 'klass', 'archived')
ordering = ('last_name', 'first_name')
list_filter = ('klass',)
list_filter = ('klass', 'archived')
search_fields = ('last_name', 'first_name', 'pcode', 'city', 'klass__name')
fields = (('last_name', 'first_name'), 'street', ('pcode', 'city'), 'email',
('tel', 'mobile'), 'birth_date', 'klass', 'archived')

View file

@ -149,12 +149,13 @@ def section_classes(request, pk):
def period_students(request, pk):
"""
Return all students from period's section and level,
Return all active students from period's section and level,
with corresponding Training if existing (JSON)
"""
period = get_object_or_404(Period, pk=pk)
students = Student.objects.filter(klass__section=period.section, klass__level=period.relative_level
).order_by('last_name')
students = Student.objects.filter(
archived=False, klass__section=period.section, klass__level=period.relative_level
).order_by('last_name')
trainings = dict((t.student_id, t.id) for t in Training.objects.filter(availability__period=period))
data = [{
'name': unicode(s),