Verified Commit 0135e3b4 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Fix LectureYearFilter if no documents yet

parent c3ce8af6
......@@ -31,11 +31,13 @@ class LectureYearFilter(admin.SimpleListFilter):
parameter_name = 'lecture_year'
def lookups(self, request, model_admin):
if AnnualDocument.objects.count() > 0:
first_year = AnnualDocument.objects.order_by('year').first().year
last_year = AnnualDocument.objects.order_by('year').last().year
return [(year, '{}-{}'.format(year, year+1))
for year in range(last_year, first_year-1, -1)]
return []
def queryset(self, request, queryset):
if not self.value():
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment