From 02fe1f9750f3da6ee4c8e4f8f6deca18b52e7e2e Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sat, 20 Sep 2025 22:10:59 +0300 Subject: [PATCH] revised colours for 'tunnelled' wallets --- core/models/wallets.py | 61 +++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/core/models/wallets.py b/core/models/wallets.py index 462db6ce3..f1a82638f 100644 --- a/core/models/wallets.py +++ b/core/models/wallets.py @@ -11,6 +11,7 @@ from django.db import models from django.urls import reverse from troggle.core.models.caves import get_cave_leniently +from troggle.core.models.survex import DrawingFile from troggle.core.models.troggle import DataIssue # from troggle.core.models.survex import SurvexBlock @@ -339,9 +340,9 @@ class Wallet(models.Model): try: for f in dirpath.iterdir(): if f.is_file(): - files.append(Path(f.name).stem) + files.append(Path(f.name)) else: - files.append(f"-{Path(f.name).stem}-") + files.append(f"-{Path(f.name)}-") except FileNotFoundError: files.append("FileNotFoundError") pass @@ -431,10 +432,26 @@ class Wallet(models.Model): # Notes, Plan, Elevation files = self.get_fnames() + sexytopo = False + for f in files: + if not isinstance(f, Path): # ignore directories which have been turned into strings + files.remove(f) + if str(f).endswith(".data.json"): # we have sexytopo data + sexytopo = True + + if sexytopo: + waldata["electronic survey"] = True + for f in files: + if str(f).endswith("ext-elevation.json"): + files.remove(f) + if str(f).endswith(".plan.json"): + files.remove(f) + if str(f).endswith(".plan.svg"): + files.remove(f) # 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) + notes_scanned = reduce(operator.or_, [f.stem.startswith("note") for f in files], False) + notes_scanned = reduce(operator.or_, [f.stem.endswith("notes") for f in files], notes_scanned) notes_required = not (notes_scanned or waldata["notes not required"]) if notes_required: ticks["N"] = "red" @@ -443,41 +460,43 @@ class Wallet(models.Model): # 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) # sexytopo does this, so we need to be clear + plan_scanned = reduce(operator.or_, [f.stem.startswith("plan") for f in files], False) + plan_scanned = reduce(operator.or_, [f.stem.endswith("plan") for f in files], plan_scanned) # sexytopo does this, so we need to be clear plan_drawing_required = not (plan_scanned or waldata["plan drawn"] or waldata["plan not required"]) if plan_drawing_required: - ticks["P"] = "red" + if waldata["electronic survey"]: + ticks["P"] = "seagreen" + else: + ticks["P"] = "red" else: ticks["P"] = "green" # Elev drawing required - elev_scanned = reduce(operator.or_, [f.startswith("elev") for f in files], False) - #elev_scanned = reduce(operator.or_, [f.endswith("elev") for f in files], elev_scanned) # sexytopo does this, so we need to be clear - elev_scanned = reduce(operator.or_, [f.endswith("elevation") for f in files], elev_scanned) + elev_scanned = reduce(operator.or_, [f.stem.startswith("elev") for f in files], False) + elev_scanned = reduce(operator.or_, [f.stem.endswith("elev") for f in files], elev_scanned) # sexytopo does this, so we need to be clear + elev_scanned = reduce(operator.or_, [f.stem.endswith("elevation") for f in files], elev_scanned) elev_drawing_required = not (elev_scanned or waldata["elev drawn"] or waldata["elev not required"]) if elev_drawing_required: - ticks["E"] = "red" + if waldata["electronic survey"]: + ticks["E"] = "seagreen" + else: + ticks["E"] = "red" else: ticks["E"] = "green" - - # if electronic, don't require P or E - if waldata["electronic survey"]: - ticks["P"] = "green" - ticks["E"] = "green" # Tunnel / Therion - # complete change in logic 2025 - ticks["T"] = "fuchsia" # default - + ticks["T"] = "red" # default is that it is not tunnelled drawings_not_required = not elev_drawing_required and not plan_drawing_required if "tunnelled" in waldata: if waldata["tunnelled"]: ticks["T"] = "green" - # if drawings_not_required and not waldata["electronic survey"]: - # ticks["T"] = "green" + elif drawings_not_required and not waldata["electronic survey"]: + ticks["T"] = "seagreen" + drawings_exists = DrawingFile.objects.filter(dwgwallets=self).exists() + if drawings_exists: + ticks["T"] = "darkgreen" # trumps everything # Website if waldata["website updated"]: