2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-15 03:17:12 +00:00

Added 'Notes not needed' checkbox

This commit is contained in:
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,11 +254,13 @@ 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)
plan_scanned = reduce(operator.or_, [f.endswith("plan") for f in files], plan_scanned)