diff --git a/core/views/scans.py b/core/views/scans.py index 0ffdb22..8c380c1 100644 --- a/core/views/scans.py +++ b/core/views/scans.py @@ -178,15 +178,14 @@ def oldwallet(request, path): return render(request, 'errors/generic.html', {'message': message}) def walletindex(request, path): - '''All years: special 'wallet' for scanned index pages + '''All years: special 'wallet' for *scanned* index pages ''' - # print([ s.walletname for s in Wallet.objects.all() ]) print(f'! - walletindex path:{path}') try: wallet = Wallet.objects.get(walletname=urlunquote(path)) return render(request, 'walletindex.html', { 'wallet':wallet, 'settings': settings }) except: - message = f'Scan folder error or not found \'{path}\' .' + message = f'Scan folder (wallet) error or not found \'{path}\' .' return render(request, 'errors/generic.html', {'message': message}) def scansingle(request, path, file): 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 = [] diff --git a/parsers/scans.py b/parsers/scans.py index b78f76f..37578cb 100644 --- a/parsers/scans.py +++ b/parsers/scans.py @@ -15,6 +15,7 @@ import settings from troggle.core.models.survex import SingleScan, Wallet, DrawingFile from troggle.core.models.troggle import DataIssue from troggle.core.utils import save_carefully, GetListDir +from troggle.core.views.scans import datewallet '''Searches through all the survey scans directories (wallets) in expofiles, looking for images to be referenced. ''' @@ -61,10 +62,13 @@ wallet_blank_html = '''
See also the documentation index for this Expo -
See also the wallet completion status for this Expo +
See also the wallet completion status for this Expo {% if logged_in %}
Reparse and reload this year's logbook by clicking here: RELOAD {% endif %} diff --git a/templates/personwallets.html b/templates/personwallets.html index f513e20..ace67a7 100644 --- a/templates/personwallets.html +++ b/templates/personwallets.html @@ -23,7 +23,7 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c
-Wallet index for this year (old script, being replaced...)
+Wallet index for this year
Logbook entries, people, Survex files for {{year}}
diff --git a/templates/yearwallets.html b/templates/yearwallets.html
index 33b86ef..e9e258a 100644
--- a/templates/yearwallets.html
+++ b/templates/yearwallets.html
@@ -23,7 +23,7 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c