From dbd9b1a0958e11744fc5653181db8d8f7e5a2fb3 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Mon, 12 Apr 2021 01:16:49 +0100 Subject: Enable svx view if url just misses off .svx --- core/views/survex.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'core/views/survex.py') diff --git a/core/views/survex.py b/core/views/survex.py index 7629af7..0818e0c 100644 --- a/core/views/survex.py +++ b/core/views/survex.py @@ -159,7 +159,7 @@ class SvxForm(forms.Form): @ensure_csrf_cookie def svx(request, survex_file): - '''Displays a singhle survex file in an textarea window (using a javascript online editor to enable + '''Displays a single survex file in an textarea window (using a javascript online editor to enable editing) with buttons which allow SAVE, check for DIFFerences from saved, and RUN (which runs the cavern executable and displays the output below the main textarea). Requires CSRF to be set upcorrect;ly, and requires permission to write to the filesystem. ''' @@ -377,7 +377,8 @@ def survexcaveslist(request): def survexcavesingle(request, survex_cave): '''parsing all the survex files of a single cave and showing that it's consistent and can find all the files and people. Should explicity fix the kataster number thing. - kataster numbers are not unique across areas. Fix this. + kataster numbers are not unique across areas. This used to be a db constraint but we need to manage + this ourselves as we don't want the parser aborting with an error message. Should use getCave() from models_caves ''' @@ -389,6 +390,11 @@ def survexcavesingle(request, survex_cave): except ObjectDoesNotExist: # can get here if the survex file is in a directory labelled with unofficial number not kataster number. # maybe - and _ mixed up, or CUCC-2017- instead of 2017-CUCC-, or CUCC2015DL01 . Let's not get carried away.. + + # or it might be an exact search for a specific survefile but just missing the '.svx. + if (Path(survexdatasetpath) / Path(survex_cave + ".svx")).is_file(): + return svx(request, survex_cave) + for unoff in [sc, sc.replace('-','_'), sc.replace('_','-'), sc.replace('-',''), sc.replace('_','')]: try: cave = Cave.objects.get(unofficial_number=unoff) # return on first one we find -- cgit v1.2.3