From 54ffab3e93a8d3f0b3d253037eb57a7fb78012d5 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Mon, 23 Oct 2023 02:32:44 +0300 Subject: checking wallets earlier int he process --- parsers/scans.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'parsers/scans.py') diff --git a/parsers/scans.py b/parsers/scans.py index 378db66..96c490a 100644 --- a/parsers/scans.py +++ b/parsers/scans.py @@ -17,7 +17,7 @@ git = settings.GIT def set_walletyear(wallet): - _ = wallet.year() # don't need return value. Just calling this saves it as w.walletyear + _ = wallet.year() # don't need return value. Just calling this saves it as w.walletyear Syntactic. def set_JSONwalletdate(wallet): """At this point in the import process, the survex files have not been imported so @@ -30,12 +30,9 @@ def set_caves(wallet): def load_all_scans(): """This iterates through the scans directories (either here or on the remote server) and builds up the models we can access later. - - It does NOT read or validate anything in the JSON data attached to each wallet. Those checks - are done at runtime, when a wallet is accessed, not at import time. - Loads people as a simple string of fullnames. We should replace this with a list of Person slugs. - + Loads people as a simple string of fullnames. We should replace this with a list of Person slugs, + and change the wallet editor to save People as slugs. """ print(" - Loading Survey Scans") @@ -115,11 +112,11 @@ def load_all_scans(): print("", flush=True, end="") # Create the wallet object. But we don't have a date for it yet. wallet = Wallet(fpath=fpath, walletname=walletname) + wallets[walletname] = wallet set_walletyear(wallet) wallet.save() set_caves(wallet) - wallets[walletname] = wallet - + singlescan = SingleScan(ffile=fpath, name=p.name, wallet=wallet) singlescan.save() @@ -160,7 +157,6 @@ def load_all_scans(): wallet, created = Wallet.objects.update_or_create(walletname=walletname, fpath=fpath) wallets[walletname] = wallet # Now also load the json - # BUT can't check linked survex blocks as they haven't been imported yet set_JSONwalletdate(wallet) set_walletyear(wallet) set_caves(wallet) @@ -170,8 +166,17 @@ def load_all_scans(): ) wallet.save() print(f"\n - found another {wjson:,} JSON files, making a total of {len(wallets):,} wallets") - + # Only the 1999 wallets have filenames which mean that the walletyear will be unset: wallets = Wallet.objects.filter(walletyear=None) for w in wallets: - w.walletyear = datetime.date(1999, 1, 1) + w.walletyear = datetime.date(1999, 1, 1) + + # Although the survex files haven't been processed yet, we can at least check if the wallets refer to a real file or not + for wallet in Wallet.objects.all(): + # this reads JSON + wallet.check_survexlist() + + + + -- cgit v1.2.3