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) diff --git a/core/views/wallets_edit.py b/core/views/wallets_edit.py index 1484639..c601667 100644 --- a/core/views/wallets_edit.py +++ b/core/views/wallets_edit.py @@ -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"] diff --git a/parsers/logbooks.py b/parsers/logbooks.py index a8469e1..1ae7fb9 100644 --- a/parsers/logbooks.py +++ b/parsers/logbooks.py @@ -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: diff --git a/templates/walletform.html b/templates/walletform.html index fb0ecdd..b1681f3 100644 --- a/templates/walletform.html +++ b/templates/walletform.html @@ -194,6 +194,9 @@
+
+ +