forked from expo/troggle
revised colours for 'tunnelled' wallets
This commit is contained in:
@@ -11,6 +11,7 @@ from django.db import models
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from troggle.core.models.caves import get_cave_leniently
|
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.troggle import DataIssue
|
||||||
|
|
||||||
# from troggle.core.models.survex import SurvexBlock
|
# from troggle.core.models.survex import SurvexBlock
|
||||||
@@ -339,9 +340,9 @@ class Wallet(models.Model):
|
|||||||
try:
|
try:
|
||||||
for f in dirpath.iterdir():
|
for f in dirpath.iterdir():
|
||||||
if f.is_file():
|
if f.is_file():
|
||||||
files.append(Path(f.name).stem)
|
files.append(Path(f.name))
|
||||||
else:
|
else:
|
||||||
files.append(f"-{Path(f.name).stem}-")
|
files.append(f"-{Path(f.name)}-")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
files.append("FileNotFoundError")
|
files.append("FileNotFoundError")
|
||||||
pass
|
pass
|
||||||
@@ -431,10 +432,26 @@ class Wallet(models.Model):
|
|||||||
|
|
||||||
# Notes, Plan, Elevation
|
# Notes, Plan, Elevation
|
||||||
files = self.get_fnames()
|
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 required
|
||||||
notes_scanned = reduce(operator.or_, [f.startswith("note") for f in files], False)
|
notes_scanned = reduce(operator.or_, [f.stem.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.endswith("notes") for f in files], notes_scanned)
|
||||||
notes_required = not (notes_scanned or waldata["notes not required"])
|
notes_required = not (notes_scanned or waldata["notes not required"])
|
||||||
if notes_required:
|
if notes_required:
|
||||||
ticks["N"] = "red"
|
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']=}")
|
# 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.stem.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.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"])
|
plan_drawing_required = not (plan_scanned or waldata["plan drawn"] or waldata["plan not required"])
|
||||||
if plan_drawing_required:
|
if plan_drawing_required:
|
||||||
ticks["P"] = "red"
|
if waldata["electronic survey"]:
|
||||||
|
ticks["P"] = "seagreen"
|
||||||
|
else:
|
||||||
|
ticks["P"] = "red"
|
||||||
else:
|
else:
|
||||||
ticks["P"] = "green"
|
ticks["P"] = "green"
|
||||||
|
|
||||||
# Elev drawing required
|
# Elev drawing required
|
||||||
elev_scanned = reduce(operator.or_, [f.startswith("elev") for f in files], False)
|
elev_scanned = reduce(operator.or_, [f.stem.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.stem.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.endswith("elevation") for f in files], elev_scanned)
|
||||||
elev_drawing_required = not (elev_scanned or waldata["elev drawn"] or waldata["elev not required"])
|
elev_drawing_required = not (elev_scanned or waldata["elev drawn"] or waldata["elev not required"])
|
||||||
if elev_drawing_required:
|
if elev_drawing_required:
|
||||||
ticks["E"] = "red"
|
if waldata["electronic survey"]:
|
||||||
|
ticks["E"] = "seagreen"
|
||||||
|
else:
|
||||||
|
ticks["E"] = "red"
|
||||||
else:
|
else:
|
||||||
ticks["E"] = "green"
|
ticks["E"] = "green"
|
||||||
|
|
||||||
# if electronic, don't require P or E
|
|
||||||
if waldata["electronic survey"]:
|
|
||||||
ticks["P"] = "green"
|
|
||||||
ticks["E"] = "green"
|
|
||||||
|
|
||||||
# Tunnel / Therion
|
# Tunnel / Therion
|
||||||
# complete change in logic 2025
|
ticks["T"] = "red" # default is that it is not tunnelled
|
||||||
ticks["T"] = "fuchsia" # default
|
|
||||||
|
|
||||||
drawings_not_required = not elev_drawing_required and not plan_drawing_required
|
drawings_not_required = not elev_drawing_required and not plan_drawing_required
|
||||||
|
|
||||||
if "tunnelled" in waldata:
|
if "tunnelled" in waldata:
|
||||||
if waldata["tunnelled"]:
|
if waldata["tunnelled"]:
|
||||||
ticks["T"] = "green"
|
ticks["T"] = "green"
|
||||||
# if drawings_not_required and not waldata["electronic survey"]:
|
elif drawings_not_required and not waldata["electronic survey"]:
|
||||||
# ticks["T"] = "green"
|
ticks["T"] = "seagreen"
|
||||||
|
|
||||||
|
drawings_exists = DrawingFile.objects.filter(dwgwallets=self).exists()
|
||||||
|
if drawings_exists:
|
||||||
|
ticks["T"] = "darkgreen" # trumps everything
|
||||||
|
|
||||||
# Website
|
# Website
|
||||||
if waldata["website updated"]:
|
if waldata["website updated"]:
|
||||||
|
|||||||
Reference in New Issue
Block a user