From 8128870d57c751d0589b58f1ce88824261d36335 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sat, 24 Apr 2021 01:23:55 +0100 Subject: more robust logbooks parsing --- core/views/logbooks.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'core/views/logbooks.py') diff --git a/core/views/logbooks.py b/core/views/logbooks.py index ecf0f6b..82dbf61 100644 --- a/core/views/logbooks.py +++ b/core/views/logbooks.py @@ -176,13 +176,17 @@ def personexpedition(request, first_name='', last_name='', year=''): def logbookentry(request, date, slug): this_logbookentry = LogbookEntry.objects.filter(date=date, slug=slug) - - if len(this_logbookentry)>1: - return render(request, 'object_list.html',{'object_list':this_logbookentry}) + + if this_logbookentry: + if len(this_logbookentry)>1: + return render(request, 'object_list.html',{'object_list':this_logbookentry}) + else: + this_logbookentry=this_logbookentry[0] + return render(request, 'logbookentry.html', {'logbookentry': this_logbookentry}) else: - this_logbookentry=this_logbookentry[0] - return render(request, 'logbookentry.html', {'logbookentry': this_logbookentry}) - + msg =(f' Logbook entry slug:"{slug}" not found in database on date:"{date}" ') + print(msg) + return render(request, 'errors/generic.html',{'message':msg}) def logbookSearch(request, extra): query_string = '' -- cgit v1.2.3