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

View File

@ -50,6 +50,7 @@ WALLET_BLANK_JSON = {
"people": ["Unknown"], "people": ["Unknown"],
"plan drawn": False, "plan drawn": False,
"plan not required": False, "plan not required": False,
"notes not required": False,
"qms written": False, "qms written": False,
"survex file": [], "survex file": [],
"survex not required": False, "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) psg = forms.CharField(strip=True, required=False)
freetext = 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)
notesnr = 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)
elevd = forms.CharField(strip=True, required=False) elevd = forms.CharField(strip=True, required=False)
@ -86,6 +88,7 @@ xlate = {
"date": "date", "date": "date",
"cave": "cave", "cave": "cave",
"plannr": "plan not required", "plannr": "plan not required",
"notesnr": "notes not required",
"survexnr": "survex not required", "survexnr": "survex not required",
"qmsw": "qms written", "qmsw": "qms written",
"elevnr": "elev not required", "elevnr": "elev not required",
@ -182,7 +185,7 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
# Notes required # Notes required
if ticks["N"] != "green": if ticks["N"] != "green":
complaints.append( 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 # 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." "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": if ticks["T"] != "green":
complaints.append( complaints.append(
"Tunnel or Therion drawing files need drawing. Or if this an electronic survey, please tick the 'Electronic survey' checkbox." "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", "plan drawn",
"elev not required", "elev not required",
"elev drawn", "elev drawn",
"notes not required",
"electronic survey", "electronic survey",
] ]
@ -629,12 +633,15 @@ def walletedit(request, path=None):
psg = "" psg = ""
freetext = "" freetext = ""
chkplannr = "" chkplannr = ""
chknotesnr = ""
chkpland = "" chkpland = ""
svxfiles = [] svxfiles = []
trips = [] trips = []
checked = {} checked = {}
context = {} context = {}
if waldata: # should always be true as populated by blank data if json file doesn't exist 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 ( if (
not waldata["date"] not waldata["date"]

View File

@ -138,7 +138,8 @@ def GetTripPersons(trippeople, expedition, logtime_underground, tid=None):
author = personyear author = personyear
else: else:
# a person but with * prefix. Ignored everywhere. # 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 author:
if not res: if not res:

View File

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