2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 08:41:51 +00:00

Added 'Notes not needed' checkbox

This commit is contained in:
Philip Sargent 2023-02-02 17:39:56 +00:00
parent 25e00e02b7
commit e0a198bac5
4 changed files with 38 additions and 20 deletions

View File

@ -45,7 +45,7 @@ class Wallet(models.Model):
jsonfile = Path(settings.DRAWINGS_DATA, "walletjson") / wyear / wname / "contents.json"
if not Path(jsonfile).is_file():
# print(f'{jsonfile} is not a file')
print(f'{jsonfile} is not a file')
return None
else:
with open(jsonfile) as json_f:
@ -177,14 +177,14 @@ class Wallet(models.Model):
ticks = {}
waldata = self.get_json()
if not waldata:
ticks["S"] = "black"
ticks["C"] = "black"
ticks["Q"] = "black"
ticks["N"] = "black"
ticks["P"] = "black"
ticks["E"] = "black"
ticks["T"] = "black"
ticks["W"] = "black"
ticks["S"] = "darkgrey"
ticks["C"] = "darkgrey"
ticks["Q"] = "darkgrey"
ticks["N"] = "darkgrey"
ticks["P"] = "darkgrey"
ticks["E"] = "darkgrey"
ticks["T"] = "darkgrey"
ticks["W"] = "darkgrey"
return ticks
ticks = {}
@ -211,14 +211,16 @@ class Wallet(models.Model):
ngood += 1
else:
nbad += 1
if nbad == 0 and ngood >= 1:
if nbad == 0 and ngood >= 1: # all valid
ticks["S"] = "green"
elif nbad >= 1 and ngood >= 1:
elif nbad >= 1 and ngood >= 1: # some valid, some invalid
ticks["S"] = "orange"
elif nbad >= 1 and ngood == 0:
elif nbad >= 1 and ngood == 0: # all bad
ticks["S"] = "red"
elif nbad == 0 and ngood == 0: # list of blank strings
ticks["S"] = "red"
else:
ticks["S"] = "black"
ticks["S"] = "fuchsia" # have fun working out what this means
# Cave Description
if waldata["description written"]:
@ -236,6 +238,9 @@ class Wallet(models.Model):
if int(self.year()) < 2015:
ticks["Q"] = "lightgrey"
if 'notes not required' not in waldata:
waldata['notes not required'] = False
# Notes, Plan, Elevation; Tunnel
if waldata["electronic survey"]:
ticks["N"] = "green"
@ -249,10 +254,12 @@ class Wallet(models.Model):
# Notes required
notes_scanned = reduce(operator.or_, [f.startswith("note") for f in files], False)
notes_scanned = reduce(operator.or_, [f.endswith("notes") for f in files], notes_scanned)
if notes_scanned:
ticks["N"] = "green"
else:
notes_required = not (notes_scanned or waldata["notes not required"])
if notes_required:
ticks["N"] = "red"
else:
ticks["N"] = "green"
print(f"{self.walletname} {ticks['N'].upper()} {notes_scanned=} {notes_required=} {waldata['notes not required']=}")
# Plan drawing required
plan_scanned = reduce(operator.or_, [f.startswith("plan") for f in files], False)

View File

@ -50,6 +50,7 @@ WALLET_BLANK_JSON = {
"people": ["Unknown"],
"plan drawn": False,
"plan not required": False,
"notes not required": False,
"qms written": False,
"survex file": [],
"survex not required": False,
@ -72,6 +73,7 @@ class WalletForm(forms.Form): # not a model-form, just a form-form
psg = forms.CharField(strip=True, required=False)
freetext = forms.CharField(strip=True, required=False)
plannr = forms.CharField(strip=True, required=False)
notesnr = forms.CharField(strip=True, required=False)
electronic = forms.CharField(strip=True, required=False)
pland = forms.CharField(strip=True, required=False)
elevd = forms.CharField(strip=True, required=False)
@ -86,6 +88,7 @@ xlate = {
"date": "date",
"cave": "cave",
"plannr": "plan not required",
"notesnr": "notes not required",
"survexnr": "survex not required",
"qmsw": "qms written",
"elevnr": "elev not required",
@ -182,7 +185,7 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
# Notes required
if ticks["N"] != "green":
complaints.append(
"The notes needs scanning (or renaming): no noteNN.jpg or XXnote.jpg file found; and this is not an electronic survey."
"The notes needs scanning (or renaming) or tick 'Notes not required' checkbox. No noteNN.jpg or XXnote.jpg file was found; this is not an electronic survey."
)
# Plan drawing required
@ -197,7 +200,7 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
"The elevation needs drawing (or renaming, or tick 'Elev drawn' checkbox or 'Elev not required' checkbox): no elevNN.jpg or XXelev.jpg file found."
)
# ETherion
# Therion
if ticks["T"] != "green":
complaints.append(
"Tunnel or Therion drawing files need drawing. Or if this an electronic survey, please tick the 'Electronic survey' checkbox."
@ -479,6 +482,7 @@ def walletedit(request, path=None):
"plan drawn",
"elev not required",
"elev drawn",
"notes not required",
"electronic survey",
]
@ -629,12 +633,15 @@ def walletedit(request, path=None):
psg = ""
freetext = ""
chkplannr = ""
chknotesnr = ""
chkpland = ""
svxfiles = []
trips = []
checked = {}
context = {}
if waldata: # should always be true as populated by blank data if json file doesn't exist
if 'notes not required' not in waldata:
waldata['notes not required'] = False
if (
not waldata["date"]

View File

@ -138,7 +138,8 @@ def GetTripPersons(trippeople, expedition, logtime_underground, tid=None):
author = personyear
else:
# a person but with * prefix. Ignored everywhere.
print(f" ! - {expedition.year} * person : {tripperson}")
# print(f" ! - {expedition.year} * person : {tripperson}")
pass
if not author:
if not res:

View File

@ -194,6 +194,9 @@
<br>
<label for="elevd">Elevation drawn ?</label>
<input {% if not user.username %} disabled{% endif %} type="checkbox" name="elevd" id="elevd" value="True" {% if "elev drawn" in checked %}checked{% endif %}>
<br>
<label for="notesnr">Notes not required ?</label>
<input {% if not user.username %} disabled{% endif %} type="checkbox" name="notesnr" id="notesnr" value=" True" {% if "notes not required" in checked %}checked{% endif %}>
<br>
<label for="descriptionw">Cave description written (or nothing recorded) ?</label>
<input {% if not user.username %} disabled{% endif %} type="checkbox" name="descriptionw" id="descriptionw" value="True" {% if "description written" in checked %}checked{% endif %}>