summaryrefslogtreecommitdiffstats
path: root/core/views/uploads.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2022-08-01 17:32:35 +0300
committerPhilip Sargent <philip.sargent@klebos.com>2022-08-01 17:32:49 +0300
commit0fd3cf43e8c9b2f1166d40d7c8edd2f6bc7b4e35 (patch)
treebf4d7a54bd5842a30499872576a12ba2f58c5044 /core/views/uploads.py
parentc1aaf0788524e69872162362b73504d89737c55d (diff)
downloadtroggle-0fd3cf43e8c9b2f1166d40d7c8edd2f6bc7b4e35.tar.gz
troggle-0fd3cf43e8c9b2f1166d40d7c8edd2f6bc7b4e35.tar.bz2
troggle-0fd3cf43e8c9b2f1166d40d7c8edd2f6bc7b4e35.zip
formatting
Diffstat (limited to 'core/views/uploads.py')
-rw-r--r--core/views/uploads.py42
1 files changed, 18 insertions, 24 deletions
diff --git a/core/views/uploads.py b/core/views/uploads.py
index 685f7bf..a8908d0 100644
--- a/core/views/uploads.py
+++ b/core/views/uploads.py
@@ -101,9 +101,10 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
'''Taken from old script wallets.py and edited to make more comprehensible
Loads the survex files names and processes all complaints
- All needs to be restructred to use the get_ticks() function on the Wallets class in core/models/survex.py
- which does the same thing
'''
+ w = Wallet.objects.get(walletname=wallet)
+ ticks = w.get_ticks()
+
# Date
if not waldata["date"]:
complaints.append("A date is mandatory. No data can be updated or edited unless you specify a date. Look in the survex file if there is one.")
@@ -111,7 +112,8 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
# People
if waldata["people"]==["NOBODY"] or waldata["people"]==["Unknown"]:
complaints.append("Someody must have done this. Look in the survex file, or in the logbook entries for this date, for the people who created this data.")
-
+
+ # survex, but get_ticks has already done much of this ??
survex_complaint = ""
if waldata["survex file"]:
@@ -133,33 +135,23 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
survex_complaint = "A survex file is required, but has not been specified!"
if survex_complaint:
complaints.append(survex_complaint)
-
+
+
# Notes required
- if not waldata["electronic survey"]:
- notes_scanned = reduce(operator.or_, [f.startswith("note") for f in files], False)
- notes_scanned = reduce(operator.or_, [Path(f).stem.endswith("notes") for f in files], notes_scanned)
- if not notes_scanned:
- complaints.append("The notes needs scanning (or renaming): no noteNN.jpg or XXnote.jpg file found; and this is not an electronic survey.")
+ 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.")
# Plan drawing required
- plan_scanned = reduce(operator.or_, [f.startswith("plan") for f in files], False)
- plan_scanned = reduce(operator.or_, [Path(f).stem.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:
- complaints.append("The plan needs drawing (or renaming, or tick 'Plan drawn' checkbox or 'Plan not required' checkbox): no planNN.jpg or XXplan.jpg file found.")
+ if ticks['P'] != "green":
+ complaints.append("The plan needs drawing (or renaming, or tick 'Plan drawn' checkbox or 'Plan not required' checkbox): no planNN.jpg or XXplan.jpg file found.")
# Elev drawing required
- elev_scanned = reduce(operator.or_, [f.startswith("elev") for f in files], False)
- elev_scanned = reduce(operator.or_, [Path(f).stem.endswith("elev") for f in files], elev_scanned)
- elev_scanned = reduce(operator.or_, [Path(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:
+ if ticks['E'] != "green":
complaints.append("The elevation needs drawing (or renaming, or tick 'Elev drawn' checkbox or 'Elev not required' checkbox): no elevNN.jpg or XXelev.jpg file found.")
- # Electronic Surveys
- if not waldata["electronic survey"]:
- if elev_drawing_required or plan_drawing_required:
- complaints.append("Tunnel or Therion drawing files need drawing. Or if this an electronic survey, please tick the 'Electronic survey' checkbox.")
+ # ETherion
+ 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.")
# Description
if not waldata["description written"]:
@@ -188,7 +180,7 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
complaints.append(f'The cave ID \'{waldata["cave"]}\' is not recognised. Please fix it.')
caveobject = None
else:
- complaints.append(f'No cave ID is given. Please give an ID, even if it is just "surface survey" or "scraps found in hut"')
+ complaints.append(f'No cave ID is given. Please give some text, even if it is just "surface survey" or "scraps found in hut"')
caveobject = None
@@ -204,6 +196,8 @@ def scanupload(request, path=None):
This subsumes much of the code which was in the old wallets.py script and so this function is very long
indeed and needs refactoring.
+
+ REWRITE bits using the ticklist, dateify, caveify, populate etc utility functions in core.view.scans.py
'''
filesaved = False
actual_saved = []