From 6deabb298839cb5322e1fda83ee102fdb4cf9ee4 Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Tue, 2 Apr 2024 09:49:24 +0200 Subject: [PATCH] add try-except around publishing preprocessor --- scipost_django/journals/context_processors.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/scipost_django/journals/context_processors.py b/scipost_django/journals/context_processors.py index 6771d622e..b75634cca 100644 --- a/scipost_django/journals/context_processors.py +++ b/scipost_django/journals/context_processors.py @@ -7,13 +7,18 @@ from .models import Journal, Publication def publishing_years_processor(request): """List of years where publishing activity took place, going backwards in time.""" - return { - "publishing_years": range( - Publication.objects.published().first().publication_date.year, - Publication.objects.published().last().publication_date.year, - -1, - ) - } + try: + context = { + "publishing_years": range( + Publication.objects.published().first().publication_date.year, + Publication.objects.published().last().publication_date.year, + -1, + ) + } + except: + context = {"publishing_years": []} + + return context def journals_processor(request): -- GitLab