From bb65ffaee60c365c29e1b08cf6adc83bdb230164 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sun, 17 Jul 2022 15:22:26 +0300 Subject: [PATCH] bugfix --- core/views/uploads.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/core/views/uploads.py b/core/views/uploads.py index 91bed4f..b59ee01 100644 --- a/core/views/uploads.py +++ b/core/views/uploads.py @@ -162,18 +162,22 @@ def get_complaints(complaints, waldata, svxfiles, files): complaints.append("The cave description website is marked as needing updating using the guidebook description from the survex file. Tick the 'Website updated' checkbox when this is done.") # FInd the cave, if it exists - try: - caveobject = getCave(waldata["cave"]) - print(f'getCave for id "{waldata["cave"]}" {caveobject}') - if not caveobject.url == waldata["description url"]: - complaints.append(f'The URL of cave description \"{waldata["description url"]}\" does not match the one on record for this cave which is: "{caveobject.url}". If the wallet is not for a cave, put a useful URL here.') - except Cave.MultipleObjectsReturned: - complaints.append(f'The cave ID \'{waldata["cave"]}\' is AMBIGUOUS. Please fix it.') + if waldata["cave"]: + try: + caveobject = getCave(waldata["cave"]) + print(f'getCave for id "{waldata["cave"]}" {caveobject}') + if not caveobject.url == waldata["description url"]: + complaints.append(f'The URL of cave description \"{waldata["description url"]}\" does not match the one on record for this cave which is: "{caveobject.url}". If the wallet is not for a cave, put a useful URL here.') + except Cave.MultipleObjectsReturned: + complaints.append(f'The cave ID \'{waldata["cave"]}\' is AMBIGUOUS. Please fix it.') + caveobject = None + except ObjectDoesNotExist: + complaints.append(f'The cave ID \'{waldata["cave"]}\' is not recognised. Please fix it.') + caveobject = None + else: + complaints.append(f'No cave ID is given. Please give an ID, even if it is just "surface survey" or "scraps found in hut"') caveobject = None - except ObjectDoesNotExist: - complaints.append(f'The cave ID \'{waldata["cave"]}\' is not recognised. Please fix it.') - caveobject = None - + return complaints, caveobject