2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

catch crashes when no data has been imported

This commit is contained in:
Philip Sargent 2022-09-12 20:50:57 +03:00
parent 6452a7beed
commit 785845598f
2 changed files with 12 additions and 3 deletions

View File

@ -84,7 +84,11 @@ def expedition(request, expeditionname):
#print('! - expo {expeditionanme} using cached page')
return render(request,'expedition.html', { **ts[expeditionname], 'logged_in' : logged_in })
this_expedition = Expedition.objects.get(year=int(expeditionname))
try:
this_expedition = Expedition.objects.get(year=int(expeditionname))
except:
message = f'Expedition not found - database apparently empty, you probably need to do a full re-import of all data.'
return render(request, 'errors/generic.html', {'message': message})
expeditions = Expedition.objects.all()
personexpeditiondays = [ ]

View File

@ -515,8 +515,13 @@ def scanupload(request, path=None):
f = Path(settings.SURVEX_DATA) / svx
if f.is_file():
path = svx.parent / svx.stem
#print(f' - {path=}')
svxfile = SurvexFile.objects.get(path=path)
#print(f' - {path=}')
try:
svxfile = SurvexFile.objects.get(path=path)
except:
message = f'Specified survex file not found - database apparently empty, you probably need to do a full re-import of all data.'
return render(request, 'errors/generic.html', {'message': message})
print(f' - {svxfile=}')
caves.append(svxfile.cave)
caverefs.append(svxfile.cave.reference())