From 1e00e565223f25658ccd1c0bbb88b1de14bfc19d Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Mon, 5 Feb 2024 20:02:03 +0000 Subject: [PATCH] check for non-existent expo --- core/views/uploads.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/views/uploads.py b/core/views/uploads.py index 136744b..5fa7d3b 100644 --- a/core/views/uploads.py +++ b/core/views/uploads.py @@ -252,7 +252,23 @@ def logbookedit(request, year=None, slug=None): LogbookEntry.objects.filter(slug=slug).delete() print(f"- Creating the LogBookEntry {slug}") + year = slug[0:4] + try: + expedition = Expedition.objects.get(year=year) + except Expedition.DoesNotExist: + message = f'''! - This expo "{year}" not created yet + It needs to be created before you can save a logbook entry. + See /handbook/computing/newyear.html + + WHAT TO DO NOW: + 1. Press the Back button on your proswer to return to the screen where you typed up the entry, + 2. Copy the text of what you wrote into a new text file, + 3. Direct a nerd to fix this. It should take only a couple of minutes.''' + print(message) + return render(request, "errors/generic.html", {"message": message}) store_edited_entry_into_database(date, place, title, entry, others, author, tu, slug) + + print(f"- Rewriting the entire {year} logbook to disc ") filename= "logbook.html" try: