Commit 8bc4bcbd authored by Joren Vrancken's avatar Joren Vrancken
Browse files

Merge branch 'fix/documents-unavailable' into 'master'

Fix LectureYearFilter if no documents yet

See merge request thalia/concrexit!839
parents c3ce8af6 0135e3b4
......@@ -31,11 +31,13 @@ class LectureYearFilter(admin.SimpleListFilter):
parameter_name = 'lecture_year'
def lookups(self, request, model_admin):
first_year = AnnualDocument.objects.order_by('year').first().year
last_year = AnnualDocument.objects.order_by('year').last().year
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 [(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