2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-21 23:01:52 +00:00

recognise old cave id codes in old wallets "1623-"

This commit is contained in:
Philip Sargent 2023-09-16 13:53:05 +03:00
parent a8d4b05617
commit 9db0b2a191

View File

@ -86,17 +86,26 @@ def fillblankpeople(w):
# print(f' - {wp=} {nobody=}')
populatewallet(w)
def is_cave(id):
def is_cave(wallet, id):
if not id:
return False
Gcavelookup = GetCaveLookup()
id = id.strip("' []'")
if id in Gcavelookup:
return True
else:
print(f" - Failed to find cave object from id <{id}>")
if id.lower() != "unknown" and id != "":
print(f" - adding <{id}> to pendingcaves.txt list")
add_cave_to_pending_list(id, f"Could not find id <{id}>")
return False
# Historic wallets used just 2 or 3 digits and were all 1623 area. So, just for these wallets,
# assume it is 1623-xxx
if f"1623-{id}" in Gcavelookup:
print(f" - Should modify wallet {wallet} to us 1623- prefix for cave <{id}>")
Gcavelookup[id] = Gcavelookup[f"1623-{id}"] # restoring ambiguous alias
return True
else:
print(f" - Wallet {wallet} Failed to find cave object from id <{id}>")
if id.lower() != "unknown" and id != "":
print(f" - adding <{id}> to pendingcaves.txt list")
add_cave_to_pending_list(id, f"Wallet {wallet} - Could not find id <{id}>")
return False
def fillblankothers(w):
"""This is on the way to having a many:many relationship between Caves and Wallets
@ -113,17 +122,17 @@ def fillblankothers(w):
if type(wcaveid) == list:
for i in wcaveid:
i = i.strip("' []'")
if is_cave(i):
if is_cave(w,i):
w.caveobj = Gcavelookup[i] # just sets it to the last one found. nasty. bug waiting to happen
elif wcaveid.find(',') != -1:
# it's a list of cave ids as a string
ids = wcaveid.split(',')
for i in ids:
i = i.strip("' []'")
if is_cave(i):
if is_cave(w,i):
w.caveobj = Gcavelookup[i] # just sets it to the last one found. nasty. bug waiting to happen
else:
if is_cave(wcaveid):
if is_cave(w,wcaveid):
w.caveobj = Gcavelookup[wcaveid.strip("' []'")]
@ -267,7 +276,7 @@ def cavewallets(request, caveid):
ids = cleanid.split(',')
for i in ids:
i = i.strip("' []'")
if is_cave(i):
if is_cave(z,i):
fcave = Gcavelookup[i.strip("' []'")] # just sets it to the last one found. nasty. bug waiting to happen
elif cleanid in Gcavelookup: