mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-15 10:37:07 +00:00
tidy with new multicave wallets
This commit is contained in:
@@ -128,7 +128,7 @@ def is_cave(wallet, id):
|
||||
print(f" - Wallet {wallet} Failed to find cave object from id <{id}>")
|
||||
if id.lower() != "unknown" and id != "":
|
||||
print(f" - adding <{id}> to pendingcaves DataIssues")
|
||||
add_cave_to_pending_list(id, wallet, f"Wallet {wallet} - Could not find id <{id}>")
|
||||
add_cave_to_pending_list(id, wallet, f"Wallet {wallet} - Could not find cave id <{id}>")
|
||||
return False
|
||||
|
||||
def fillblankothers(w):
|
||||
@@ -260,11 +260,15 @@ def walletslistperson(request, slug):
|
||||
|
||||
manywallets = personwallet(p)
|
||||
expeditions = Expedition.objects.all()
|
||||
print("--")
|
||||
length_ug = 0.0
|
||||
for w in manywallets:
|
||||
for sb in w.survexblock_set.all():
|
||||
length_ug += sb.legslength
|
||||
return render(
|
||||
request,
|
||||
"personwallets.html",
|
||||
{"manywallets": manywallets, "settings": settings, "person": p, "expeditions": expeditions},
|
||||
{"manywallets": manywallets, "settings": settings, "person": p, "expeditions": expeditions,
|
||||
"length_ug": length_ug}
|
||||
)
|
||||
|
||||
|
||||
@@ -309,7 +313,6 @@ def walletslistyear(request, year):
|
||||
for w in manywallets:
|
||||
for sb in w.survexblock_set.all():
|
||||
length_ug += sb.legslength
|
||||
print("--")
|
||||
return render(
|
||||
request,
|
||||
"yearwallets.html",
|
||||
@@ -336,50 +339,52 @@ def cavewallets(request, caveid):
|
||||
|
||||
# remove duplication. Sorting is done in the template
|
||||
# But this only gets wallets which have survex files attached..
|
||||
wallets = set(Wallet.objects.filter(survexblock__survexfile__cave=cave))
|
||||
# wallets = set(Wallet.objects.filter(survexblock__survexfile__cave=cave))
|
||||
|
||||
# all the ones without a survexblock attached via a *ref, search for match in JSON
|
||||
zilchwallets = set(Wallet.objects.exclude(survexblock__survexfile__cave=cave))
|
||||
for z in zilchwallets:
|
||||
zcaveid = z.cave()
|
||||
if zcaveid:
|
||||
cleanid = str(zcaveid).strip("' []'")
|
||||
# zilchwallets = set(Wallet.objects.exclude(survexblock__survexfile__cave=cave))
|
||||
# for z in zilchwallets:
|
||||
# zcaveid = z.cave() # read JSON
|
||||
# if zcaveid:
|
||||
# cleanid = str(zcaveid).strip("' []\"")
|
||||
|
||||
if cleanid.find(',') != -1:
|
||||
# it's a list of cave ids
|
||||
wurl = f"/walletedit/{z.walletname.replace('#',':')}"
|
||||
message = f" ! In {z.walletname} cavewallets, we do not handle lists of cave ids yet '{cleanid}'"
|
||||
print(message)
|
||||
DataIssue.objects.update_or_create(parser="scans", message=message, url=wurl)
|
||||
|
||||
# it's a list of cave ids as a string. Identify any orphan caves hidden here
|
||||
ids = cleanid.split(',')
|
||||
for i in ids:
|
||||
i = i.strip("' []'")
|
||||
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:
|
||||
fcave = Gcavelookup[cleanid]
|
||||
if str(fcave.slug()) == caveid:
|
||||
# print(f' - Found one ! {z.walletname=} {zcaveid=}')
|
||||
wallets.add(z)
|
||||
elif f"1623-{cleanid}" in Gcavelookup: # special hack for all the old wallets which are 1623
|
||||
fcave = Gcavelookup[f"1623-{cleanid}"]
|
||||
if str(fcave.slug()) == caveid:
|
||||
# print(f' - Found one ! {z.walletname=} {zcaveid=}')
|
||||
wallets.add(z)
|
||||
elif cleanid in ['surface', 'unknown', '']:
|
||||
# message = f" ! In {z.walletname} cavewallets, ignoring '{cleanid}' as not a cave"
|
||||
# if cleanid.find(',') != -1:
|
||||
# # it's a list of cave ids
|
||||
# wurl = f"/walletedit/{z.walletname.replace('#',':')}"
|
||||
# message = f" ! In {z.walletname} cavewallets, we do not handle lists of cave ids yet '{cleanid}'"
|
||||
# print(message)
|
||||
pass
|
||||
else:
|
||||
wurl = f"/walletedit/{z.walletname.replace('#',':')}"
|
||||
message = f" ! In {z.walletname} cavewallets, there is an unrecognised cave name '{cleanid}', adding to pending list."
|
||||
print(message)
|
||||
DataIssue.objects.update_or_create(parser="scans", message=message, url=wurl)
|
||||
add_cave_to_pending_list(cleanid, z, f"an unrecognised cave name in {z.walletname}")
|
||||
# DataIssue.objects.update_or_create(parser="scans", message=message, url=wurl)
|
||||
|
||||
# # it's a list of cave ids as a string. Identify any orphan caves hidden here
|
||||
# ids = cleanid.split(',')
|
||||
# for i in ids:
|
||||
# i = i.strip("' []'")
|
||||
# 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:
|
||||
# fcave = Gcavelookup[cleanid]
|
||||
# if str(fcave.slug()) == caveid:
|
||||
# # print(f' - Found one ! {z.walletname=} {zcaveid=}')
|
||||
# wallets.add(z)
|
||||
# elif f"1623-{cleanid}" in Gcavelookup: # special hack for all the old wallets which are 1623
|
||||
# fcave = Gcavelookup[f"1623-{cleanid}"]
|
||||
# if str(fcave.slug()) == caveid:
|
||||
# # print(f' - Found one ! {z.walletname=} {zcaveid=}')
|
||||
# wallets.add(z)
|
||||
# elif cleanid in ['surface', 'unknown', '']:
|
||||
# # message = f" ! In {z.walletname} cavewallets, ignoring '{cleanid}' as not a cave"
|
||||
# # print(message)
|
||||
# pass
|
||||
# else:
|
||||
# wurl = f"/walletedit/{z.walletname.replace('#',':')}"
|
||||
# message = f" ! In {z.walletname} cavewallets, there is an unrecognised cave name '{cleanid}', adding to pending list."
|
||||
# print(message)
|
||||
# DataIssue.objects.update_or_create(parser="scans", message=message, url=wurl)
|
||||
# add_cave_to_pending_list(cleanid, z, f"an unrecognised cave name in {z.walletname}")
|
||||
|
||||
# or now:
|
||||
wallets = cave.wallets.all()
|
||||
manywallets = list(set(wallets))
|
||||
for w in manywallets:
|
||||
fillblankpeople(w)
|
||||
@@ -387,11 +392,15 @@ def cavewallets(request, caveid):
|
||||
w.ticks = w.get_ticks() # the complaints in colour form, from the json file on disc
|
||||
fixsurvextick(w, w.ticks)
|
||||
expeditions = Expedition.objects.all()
|
||||
print("--")
|
||||
length_ug = 0.0
|
||||
for w in manywallets:
|
||||
for sb in w.survexblock_set.all():
|
||||
length_ug += sb.legslength
|
||||
return render(
|
||||
request,
|
||||
"cavewallets.html",
|
||||
{"manywallets": manywallets, "settings": settings, "cave": cave, "expeditions": expeditions},
|
||||
{"manywallets": manywallets, "settings": settings, "cave": cave, "expeditions": expeditions,
|
||||
"length_ug": length_ug}
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user