diff options
Diffstat (limited to 'core/views/uploads.py')
-rw-r--r-- | core/views/uploads.py | 42 |
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 = [] |