diff options
Diffstat (limited to 'core/views/logbooks.py')
-rw-r--r-- | core/views/logbooks.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/core/views/logbooks.py b/core/views/logbooks.py index 4c88d03..c71bab0 100644 --- a/core/views/logbooks.py +++ b/core/views/logbooks.py @@ -3,6 +3,7 @@ import re from django.db.models import Q from django.shortcuts import redirect, render from django.views.generic.list import ListView +from django.core.exceptions import ValidationError import troggle.settings as settings from troggle.core.models.logbooks import QM, LogbookEntry, PersonLogEntry, writelogbook @@ -307,8 +308,17 @@ def logreport(request, year=1999): return render(request, "errors/generic.html", {"message": msg}) def logbookentry(request, date, slug): - # start = time.time() - trips = LogbookEntry.objects.filter(date=date) # all the trips not just this one + """Displays a single logbook entry + however, if an author has not used the correct URL in an image or a reference, then a link from + inside a logbook entry can arrive with this default address prefix. So we + have to handle that error without crashing. + """ + try: + trips = LogbookEntry.objects.filter(date=date) # all the trips not just this one + except ValidationError: + msg = f' Logbook entry invalid date:"{date}" probably because of relative (not absolute) addressing of "src=" or "haref=" in the text' + print(msg) + return render(request, "errors/generic.html", {"message": msg}) this_logbookentry = trips.filter(date=date, slug=slug) year = slug[:4] |