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 = '''

Wallet WALLET

''' def CheckEmptyDate(wallet): - '''If date is not set, get it from a linked survex file. If several, pick the earliest. - - Maybe also look at filedates for the scans in expofiles/surveyscans/ , but these can be re-set by copying. + '''If date is not set, get it from a linked survex file. + Could also look at filedates for the scans in expofiles/surveyscans/ , but these can be re-set by copying. ''' + earliest = datetime.datetime.now().date() + + # This is not working, can't see why. An scans parser now taking a very long time.. + #datewallet(wallet, earliest) return def CheckEmptyPeople(wallet): @@ -73,6 +77,8 @@ def CheckEmptyPeople(wallet): To be a Troggle model change; a many:many relationship between wallets and people, as well as being a list in the JSON file (which is the permanent repository). We want the many:many relationship so that we can filter wallets based on a person. + + For the moment, we will just get a list.. ''' return @@ -147,6 +153,7 @@ def load_all_scans(): # first do the smkhs (large kh survey scans) directory # this seems to be never used ?! + #We should load all the scans, even for nonstandard names. manywallets_smkhs = Wallet(fpath=os.path.join(settings.SCANS_ROOT, "../surveys/smkhs"), walletname="smkhs") print("smkhs", end=' ') if os.path.isdir(manywallets_smkhs.fpath): @@ -170,19 +177,14 @@ def load_all_scans(): # this is where we should load the contents.json for people so we can report on them later # this is where we should record the year explicitly # line 347 of view/uploads.py and needs refactoring for loading contentsjson - wallet.save() - LoadListScansFile(wallet) CheckEmptyDate(wallet) CheckEmptyPeople(wallet) + wallet.save() + LoadListScansFile(wallet) CopyWalletData(wallet) - - # what is this? - # elif walletname != "thumbs": - # print(f'\n - Wallet {walletname} - {fpath}') - # wallet = Wallet(fpath=fpath, walletname=walletname) - # wallet.save() - # LoadListScansFile(wallet) + else: + # but We should load all the scans, even for nonstandard names. print(f'\n - IGNORE {walletname} - {fpath}') diff --git a/templates/cavewallets.html b/templates/cavewallets.html index 8ce1da1..4c61e63 100644 --- a/templates/cavewallets.html +++ b/templates/cavewallets.html @@ -23,7 +23,7 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c {{wallet.walletname}} - {{wallet.date}} + {% if wallet.date %}{{wallet.date}}{% else %} {% endif %} {{wallet.name}} {{wallet.persons}} diff --git a/templates/expedition.html b/templates/expedition.html index 98cc871..7146099 100644 --- a/templates/expedition.html +++ b/templates/expedition.html @@ -18,7 +18,7 @@ {% endfor %}

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.walletname}} - {{wallet.date}} + {% if wallet.date %}{{wallet.date}}{% else %} {% endif %} {{wallet.name}} {{wallet.persons}} {{wallet.cave}} diff --git a/templates/tasks.html b/templates/tasks.html index 3ba9b3a..ba7fe56 100644 --- a/templates/tasks.html +++ b/templates/tasks.html @@ -57,10 +57,10 @@ ul {list-style: disc}

Unfinished wallets work to do:

Upload new data

diff --git a/templates/wallet_table.html b/templates/wallet_table.html index b239e91..1dedb3b 100644 --- a/templates/wallet_table.html +++ b/templates/wallet_table.html @@ -21,7 +21,7 @@ {{wallet.walletname}} - {{wallet.date}} + {% if wallet.date %}{{wallet.date}}{% else %} {% endif %} {{wallet.cave}} {{wallet.name}} diff --git a/templates/walletform.html b/templates/walletform.html index 37b1c11..bf859f0 100644 --- a/templates/walletform.html +++ b/templates/walletform.html @@ -60,7 +60,7 @@ {% endif %}

-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 {{wallet.walletname}} - {{wallet.date}} + {% if wallet.date %}{{wallet.date}}{% else %} {% endif %} {{wallet.name}} {{wallet.persons}} {{wallet.cave}}