diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2023-02-02 17:39:56 +0000 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2023-02-02 17:39:56 +0000 |
commit | e0a198bac522e138ef46f983b6c9455b17f787ce (patch) | |
tree | 859ff07f15290944fec67435fd3103b14bed0323 /core/models/wallets.py | |
parent | 25e00e02b76aa90fdcf6f41be56898dbe8008c9e (diff) | |
download | troggle-e0a198bac522e138ef46f983b6c9455b17f787ce.tar.gz troggle-e0a198bac522e138ef46f983b6c9455b17f787ce.tar.bz2 troggle-e0a198bac522e138ef46f983b6c9455b17f787ce.zip |
Added 'Notes not needed' checkbox
Diffstat (limited to 'core/models/wallets.py')
-rw-r--r-- | core/models/wallets.py | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/core/models/wallets.py b/core/models/wallets.py index a90a737..931a1fc 100644 --- a/core/models/wallets.py +++ b/core/models/wallets.py @@ -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) |