added free text field to wallet JSON

This commit is contained in:
Philip Sargent 2022-09-20 22:05:35 +03:00
parent 36995ec051
commit 94b49adc4e
2 changed files with 20 additions and 10 deletions

View File

@ -61,6 +61,7 @@ todo = '''
WALLET_BLANK_JSON = { WALLET_BLANK_JSON = {
"cave": "", "cave": "",
"date": "", "date": "",
"free text": "",
# "description url": "1623/NNN", # "description url": "1623/NNN",
"description written": False, "description written": False,
"electronic survey": False, "electronic survey": False,
@ -100,6 +101,7 @@ class WalletForm(forms.Form): # not a model-form, just a form-form
elevnr = forms.CharField(strip=True, required=False) elevnr = forms.CharField(strip=True, required=False)
cave = forms.CharField(strip=True, required=False) cave = forms.CharField(strip=True, required=False)
psg = forms.CharField(strip=True, required=False) psg = forms.CharField(strip=True, required=False)
freetext = forms.CharField(strip=True, required=False)
plannr = forms.CharField(strip=True, required=False) plannr = forms.CharField(strip=True, required=False)
electronic = forms.CharField(strip=True, required=False) electronic = forms.CharField(strip=True, required=False)
pland = forms.CharField(strip=True, required=False) pland = forms.CharField(strip=True, required=False)
@ -122,6 +124,7 @@ xlate = {
"pland": "plan drawn", "pland": "plan drawn",
"elevd": "elev drawn", "elevd": "elev drawn",
"psg": "name", # a name for this wallet "psg": "name", # a name for this wallet
"freetext": "free text",
"survex": "survex file", "survex": "survex file",
} }
@ -167,15 +170,15 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
try: try:
svxfile = SurvexFile.objects.get(path=sx) svxfile = SurvexFile.objects.get(path=sx)
except: except:
file_complaint = f"{wallet} Survex file name {sx} was not imported via a *include statement." file_complaint = f"{wallet} Survex file name {sx} was not imported via a *include statement so it not available."
complaints.append(file_complaint) complaints.append(file_complaint)
message = f"! {file_complaint}" message = f"! {file_complaint}"
print(message) print(message)
DataIssue.objects.update_or_create(parser='scans', message=message, url=wurl) # set URL to this wallet folder DataIssue.objects.update_or_create(parser='scans', message=message, url=wurl) # set URL to this wallet folder
if waldata["survex not required"] and waldata["survex file"] != "": if waldata["survex not required"] and waldata["survex file"] != [""]:
survex_complaint = "Survex is stated as not required and yet there is a survex file!" survex_complaint = f'Survex is stated as not required and yet there is a survex file! ({waldata["survex file"]})'
if not waldata["survex not required"] and waldata["survex file"] == "": if not waldata["survex not required"] and waldata["survex file"] == [""]:
survex_complaint = "A survex file is required, but has not been specified!" survex_complaint = "A survex file is required, but has not been specified!"
if survex_complaint: if survex_complaint:
complaints.append(survex_complaint) complaints.append(survex_complaint)
@ -231,7 +234,7 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
complaints.append(f'The cave ID \'{waldata["cave"]}\' is not recognised. Please fix it.') complaints.append(f'The cave ID \'{waldata["cave"]}\' is not recognised. Please fix it.')
caveobject = None caveobject = None
else: else:
complaints.append(f'No cave ID is given. If there is no survex file, please give some text, even if it is just "surface survey" or "scraps found in hut"') complaints.append(f'No cave ID is given. If there is no survex file, please give something, even if it is just "1623-000", "surface survey" or "scraps found in hut"')
caveobject = None caveobject = None
@ -506,6 +509,7 @@ def scanupload(request, path=None):
else: else:
metadataurl = Path("/dwgdataraw", "walletjson") / wallet[0:4] / wallet.replace("#",":") / "contents.json" metadataurl = Path("/dwgdataraw", "walletjson") / wallet[0:4] / wallet.replace("#",":") / "contents.json"
psg = "" psg = ""
freetext = ""
chkplannr = "" chkplannr = ""
chkpland = "" chkpland = ""
svxfiles = [] svxfiles = []
@ -614,8 +618,8 @@ def scanupload(request, path=None):
cave = "" cave = ""
if waldata["name"]: if waldata["name"]:
psg = waldata["name"] psg = waldata["name"]
# if not waldata["description url"]: if "free text" in waldata:
# waldata["description url"]="" freetext = waldata["free text"]
# find trips and survex files of the same date # find trips and survex files of the same date
if waldata["date"]: if waldata["date"]:
@ -668,7 +672,7 @@ def scanupload(request, path=None):
'date': waldata["date"], 'date': waldata["date"],
#'url': waldata["description url"], 'urlsize': str(len(str(waldata["description url"]))), #'url': waldata["description url"], 'urlsize': str(len(str(waldata["description url"]))),
'survex': waldata["survex file"], 'survexsize': survexsize, 'survex': waldata["survex file"], 'survexsize': survexsize,
'cave': cave, 'psg': psg, 'psgsize': str(max(12,len(str(psg))))}) 'cave': cave, 'psg': psg, 'freetext': freetext,'psgsize': str(max(12,len(str(psg)))), 'freetextsize': str(max(60,len(str(freetext))))})
else: # no wallet data: should never happen as their should be default data in all cases else: # no wallet data: should never happen as their should be default data in all cases
context = {'year': year, 'prev': prev, 'next': next, 'prevy': prevy, 'nexty': nexty, context = {'year': year, 'prev': prev, 'next': next, 'prevy': prevy, 'nexty': nexty,
'files': files, 'dirs': dirs, 'waldata': waldata, 'svxfiles': svxfiles, 'files': files, 'dirs': dirs, 'waldata': waldata, 'svxfiles': svxfiles,
@ -680,9 +684,9 @@ def scanupload(request, path=None):
return render(request, 'walletform.html', return render(request, 'walletform.html',
{'form': form, 'wallet': wallet, **context, {'form': form, 'wallet': wallet, **context,
'date': "", 'date': "",
'url': "", 'urlsize': 12, #'url': "", 'urlsize': 12,
'survex': "", 'survexsize': 46, 'survex': "", 'survexsize': 46,
'cave': cave, 'psg': psg, 'psgsize': 12}) 'cave': cave, 'psg': psg, 'freetext': freetext,'psgsize': 12, 'freetextsize': 20})
@login_required_if_public @login_required_if_public
def photoupload(request, folder=None): def photoupload(request, folder=None):

View File

@ -146,6 +146,12 @@
label = "Survey area" name = "psg" size ="{{psgsize}}" label = "Survey area" name = "psg" size ="{{psgsize}}"
title="Survey area, e.g. White Elephant or Nieder Augst Eck" title="Survey area, e.g. White Elephant or Nieder Augst Eck"
placeholder="{{psg}}" value="{{psg}}" /> placeholder="{{psg}}" value="{{psg}}" />
<br>
<label for="freetext">Free text for comments</label>
<input
label = "Free text" name = "freetext" size ="{{freetextsize}}"
title="e.g. scans for plan are in another wallet #99"
placeholder="{{freetext}}" value="{{freetext}}" />
<br> <br>
<label for="plannr">Plan not required ?</label> <label for="plannr">Plan not required ?</label>
<input type="checkbox" name="plannr" id="plannr" value=" True" {% if "plan not required" in checked %}checked{% endif %}> <input type="checkbox" name="plannr" id="plannr" value=" True" {% if "plan not required" in checked %}checked{% endif %}>