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 = {
"cave": "",
"date": "",
"free text": "",
# "description url": "1623/NNN",
"description written": 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)
cave = 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)
electronic = forms.CharField(strip=True, required=False)
pland = forms.CharField(strip=True, required=False)
@ -122,6 +124,7 @@ xlate = {
"pland": "plan drawn",
"elevd": "elev drawn",
"psg": "name", # a name for this wallet
"freetext": "free text",
"survex": "survex file",
}
@ -167,15 +170,15 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
try:
svxfile = SurvexFile.objects.get(path=sx)
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)
message = f"! {file_complaint}"
print(message)
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"] != "":
survex_complaint = "Survex is stated as not required and yet there is a survex file!"
if not waldata["survex not required"] and waldata["survex file"] == "":
if waldata["survex not required"] and waldata["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"] == [""]:
survex_complaint = "A survex file is required, but has not been specified!"
if 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.')
caveobject = None
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
@ -506,6 +509,7 @@ def scanupload(request, path=None):
else:
metadataurl = Path("/dwgdataraw", "walletjson") / wallet[0:4] / wallet.replace("#",":") / "contents.json"
psg = ""
freetext = ""
chkplannr = ""
chkpland = ""
svxfiles = []
@ -614,8 +618,8 @@ def scanupload(request, path=None):
cave = ""
if waldata["name"]:
psg = waldata["name"]
# if not waldata["description url"]:
# waldata["description url"]=""
if "free text" in waldata:
freetext = waldata["free text"]
# find trips and survex files of the same date
if waldata["date"]:
@ -668,7 +672,7 @@ def scanupload(request, path=None):
'date': waldata["date"],
#'url': waldata["description url"], 'urlsize': str(len(str(waldata["description url"]))),
'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
context = {'year': year, 'prev': prev, 'next': next, 'prevy': prevy, 'nexty': nexty,
'files': files, 'dirs': dirs, 'waldata': waldata, 'svxfiles': svxfiles,
@ -680,9 +684,9 @@ def scanupload(request, path=None):
return render(request, 'walletform.html',
{'form': form, 'wallet': wallet, **context,
'date': "",
'url': "", 'urlsize': 12,
#'url': "", 'urlsize': 12,
'survex': "", 'survexsize': 46,
'cave': cave, 'psg': psg, 'psgsize': 12})
'cave': cave, 'psg': psg, 'freetext': freetext,'psgsize': 12, 'freetextsize': 20})
@login_required_if_public
def photoupload(request, folder=None):

View File

@ -146,6 +146,12 @@
label = "Survey area" name = "psg" size ="{{psgsize}}"
title="Survey area, e.g. White Elephant or Nieder Augst Eck"
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>
<label for="plannr">Plan not required ?</label>
<input type="checkbox" name="plannr" id="plannr" value=" True" {% if "plan not required" in checked %}checked{% endif %}>