From 011e6777c9cf092bdcb8b5d9bfda8a0b86c69236 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Thu, 19 Dec 2024 22:55:08 +0000 Subject: bugfixes and more comments --- core/views/logbooks.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'core/views/logbooks.py') 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] -- cgit v1.2.3