summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/views_survex.py34
1 files changed, 22 insertions, 12 deletions
diff --git a/core/views_survex.py b/core/views_survex.py
index eb807e4..2a199d3 100644
--- a/core/views_survex.py
+++ b/core/views_survex.py
@@ -19,7 +19,9 @@ from troggle.core.models_caves import Cave, PersonTrip, LogbookEntry
from troggle.parsers.people import GetPersonExpeditionNameLookup
-survextemplatefile = """; *** DO NOT SAVE THIS FILE WITHOUT RENAMING IT !! ***
+survextemplatefile = """; *** THIS IS A TEMPLATE FILE NOT WHAT YOU MIGHT BE EXPECTING ***
+
+*** DO NOT SAVE THIS FILE WITHOUT RENAMING IT !! ***
;[Stuff in square brackets is example text to be replaced with real data,
; removing the square brackets]
@@ -31,14 +33,14 @@ survextemplatefile = """; *** DO NOT SAVE THIS FILE WITHOUT RENAMING IT !! ***
; Cave:
; Area in cave/QM:
*title ""
-*date [2040.07.04]
-*team Insts [Fred Foo]
-*team Notes [Brenda Bar]
-*team Pics [Brenda Bar]
-*team Tape [Albert Anyone]
+*date [2040.07.04] ; <-- CHANGE THIS DATE
+*team Insts [Fred Fossa]
+*team Notes [Brenda Badger]
+*team Pics [Luke Lynx]
+*team Tape [Albert Aadvark]
*instrument [SAP #+Laser Tape/DistoX/Compass # ; Clino #]
; Calibration: [Where, readings]
-*ref 2040#00
+*ref [2040#00] ; <-- CHANGE THIS TOO
; the #number is on the clear pocket containing the original notes
; if using a tape:
@@ -94,7 +96,7 @@ class SvxForm(forms.Form):
filename = forms.CharField(widget=forms.TextInput(attrs={"readonly":True}))
datetime = forms.DateTimeField(widget=forms.TextInput(attrs={"readonly":True}))
outputtype = forms.CharField(widget=forms.TextInput(attrs={"readonly":True}))
- code = forms.CharField(widget=forms.Textarea(attrs={"cols":150, "rows":18}))
+ code = forms.CharField(widget=forms.Textarea(attrs={"cols":150, "rows":36}))
def GetDiscCode(self):
fname = settings.SURVEX_DATA + self.data['filename'] + ".svx"
@@ -121,9 +123,18 @@ class SvxForm(forms.Form):
return "Error: no begin/end block here"
if mbeginend.group(1) != mbeginend.group(2):
return "Error: mismatching begin/end labels"
-
- fout = open(fname, "wt", encoding='utf8',newline='\n')
- # javascript seems to insert CRLF on WSL1.
+
+ # Make this create new survex folders if needed
+ try:
+ fout = open(fname, "wt", encoding='utf8',newline='\n')
+ except FileNotFoundError:
+ pth = os.path.dirname(self.data['filename'])
+ newpath = os.path.join(settings.SURVEX_DATA, pth)
+ if not os.path.exists(newpath):
+ os.makedirs(newpath)
+ fout = open(fname, "wt", encoding='utf8',newline='\n')
+
+ # javascript seems to insert CRLF on WSL1 whatever you say. So fix that:
res = fout.write(rcode.replace("\r",""))
fout.close()
return "SAVED ."
@@ -174,7 +185,6 @@ def svx(request, survex_file):
form.data['code'] = rcode
if "save" in rform.data:
if request.user.is_authenticated():
- #print("sssavvving")
message = form.SaveCode(rcode)
else:
message = "You do not have authority to save this file"