diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2024-12-19 22:55:08 +0000 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2024-12-19 22:55:08 +0000 |
commit | 011e6777c9cf092bdcb8b5d9bfda8a0b86c69236 (patch) | |
tree | 474dfe0908531d1cc22f14024cfa375f5c28c072 /core/views/logbooks.py | |
parent | 19bbb00dcc9d8fc2600bd782343ffff2a9fb2798 (diff) | |
download | troggle-011e6777c9cf092bdcb8b5d9bfda8a0b86c69236.tar.gz troggle-011e6777c9cf092bdcb8b5d9bfda8a0b86c69236.tar.bz2 troggle-011e6777c9cf092bdcb8b5d9bfda8a0b86c69236.zip |
bugfixes and more comments
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] |