mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-02-08 11:28:23 +00:00
checking wallets earlier int he process
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user