diff options
author | Philip Sargent <philip.sargent@klebos.com> | 2021-04-24 01:23:55 +0100 |
---|---|---|
committer | Philip Sargent <philip.sargent@klebos.com> | 2021-04-24 01:23:55 +0100 |
commit | 8128870d57c751d0589b58f1ce88824261d36335 (patch) | |
tree | 227f4912933394fe736e136e2bbd9b81d88c91a7 /core/views/logbooks.py | |
parent | b979bdb5609394902d7b727c7e27f249d4f953f3 (diff) | |
download | troggle-8128870d57c751d0589b58f1ce88824261d36335.tar.gz troggle-8128870d57c751d0589b58f1ce88824261d36335.tar.bz2 troggle-8128870d57c751d0589b58f1ce88824261d36335.zip |
more robust logbooks parsing
Diffstat (limited to 'core/views/logbooks.py')
-rw-r--r-- | core/views/logbooks.py | 16 |
1 files changed, 10 insertions, 6 deletions
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 = '' |