summaryrefslogtreecommitdiffstats
path: root/core/views/survex.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2021-04-12 01:16:49 +0100
committerPhilip Sargent <philip.sargent@klebos.com>2021-04-12 01:16:49 +0100
commitdbd9b1a0958e11744fc5653181db8d8f7e5a2fb3 (patch)
treeb6c9ecb32b6f2a3b46715887298e85537e144690 /core/views/survex.py
parentf6f83c6f704ff66f6de7d3f51c83f3960ed0011b (diff)
downloadtroggle-dbd9b1a0958e11744fc5653181db8d8f7e5a2fb3.tar.gz
troggle-dbd9b1a0958e11744fc5653181db8d8f7e5a2fb3.tar.bz2
troggle-dbd9b1a0958e11744fc5653181db8d8f7e5a2fb3.zip
Enable svx view if url just misses off .svx
Diffstat (limited to 'core/views/survex.py')
-rw-r--r--core/views/survex.py10
1 files changed, 8 insertions, 2 deletions
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