summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-07-29 18:21:07 +0300
committerPhilip Sargent <philip.sargent@gmail.com>2023-07-29 18:21:07 +0300
commit5f07f234ef8d9c5cf8c4a13d1d0afb1142dbbff9 (patch)
treeec36886ad595f1f5b586ae971c3b0931ec86db54
parentaf6081e4065f77a7bd1c322adbbebacf6d4d15cf (diff)
downloadtroggle-5f07f234ef8d9c5cf8c4a13d1d0afb1142dbbff9.tar.gz
troggle-5f07f234ef8d9c5cf8c4a13d1d0afb1142dbbff9.tar.bz2
troggle-5f07f234ef8d9c5cf8c4a13d1d0afb1142dbbff9.zip
electronic surveys still need notes
-rw-r--r--core/models/wallets.py81
-rw-r--r--core/views/wallets_edit.py4
2 files changed, 44 insertions, 41 deletions
diff --git a/core/models/wallets.py b/core/models/wallets.py
index c0a8664..ecf442c 100644
--- a/core/models/wallets.py
+++ b/core/models/wallets.py
@@ -213,6 +213,7 @@ class Wallet(models.Model):
def get_ticks(self):
"""Reads all the JSON data and sets the colour of the completion tick for each condition"""
ticks = {}
+
waldata = self.get_json()
if not waldata:
ticks["S"] = "darkgrey"
@@ -278,57 +279,59 @@ class Wallet(models.Model):
if 'notes not required' not in waldata:
waldata['notes not required'] = False
+
- # Notes, Plan, Elevation; Tunnel
- if waldata["electronic survey"]:
+ # Notes, Plan, Elevation
+ files = self.get_fnames()
+
+ # 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_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)
+ plan_drawing_required = not (plan_scanned or waldata["plan drawn"] or waldata["plan not required"])
+ if plan_drawing_required:
+ ticks["P"] = "red"
+ else:
ticks["P"] = "green"
- ticks["E"] = "green"
- ticks["T"] = "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)
+ elev_scanned = reduce(operator.or_, [f.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"
else:
+ ticks["E"] = "green"
- files = self.get_fnames()
-
- # 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_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']=}")
+ # if electronic, don't require P or E
+ if waldata["electronic survey"]:
+ # ticks["N"] = "green"
+ ticks["P"] = "green"
+ ticks["E"] = "green"
+ # ticks["T"] = "green" # No, this does not mean it has been 'tunneled' properly
- # 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)
- plan_drawing_required = not (plan_scanned or waldata["plan drawn"] or waldata["plan not required"])
- if plan_drawing_required:
- 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)
- elev_scanned = reduce(operator.or_, [f.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"
- else:
- ticks["E"] = "green"
-
- # Tunnel / Therion
- if elev_drawing_required or plan_drawing_required:
- ticks["T"] = "red"
- else:
- ticks["T"] = "green"
+ # Tunnel / Therion
+ if elev_drawing_required or plan_drawing_required:
+ ticks["T"] = "red"
+ else:
+ ticks["T"] = "green"
# Website
if waldata["website updated"]:
ticks["W"] = "green"
else:
ticks["W"] = "red"
+
return ticks
diff --git a/core/views/wallets_edit.py b/core/views/wallets_edit.py
index 9273fed..57ebd36 100644
--- a/core/views/wallets_edit.py
+++ b/core/views/wallets_edit.py
@@ -190,7 +190,7 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
# Notes required
if ticks["N"] != "green":
complaints.append(
- "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."
+ "The notes needs scanning (or renaming) or tick 'Notes not required' checkbox. No noteNN.jpg or XXnote.jpg file was found. Needed even for an electronic survey."
)
# Plan drawing required
@@ -208,7 +208,7 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
# 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."
+ "Tunnel or Therion drawing files need drawing, or tick 'Plan/Elev drawn' checkbox or 'Plan/Elev not required' checkboxes"
)
# Description