diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2023-10-21 22:31:33 +0300 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2023-10-21 22:31:33 +0300 |
commit | 1641dfe5f199e26607e8367395f4f8aa04eb376b (patch) | |
tree | efed94787898f8d395c8a1e8113a369bdd60b0e7 /core/views/scans.py | |
parent | e7a0c57330a9c3808531b4d401d0cedf0f0c0638 (diff) | |
download | troggle-1641dfe5f199e26607e8367395f4f8aa04eb376b.tar.gz troggle-1641dfe5f199e26607e8367395f4f8aa04eb376b.tar.bz2 troggle-1641dfe5f199e26607e8367395f4f8aa04eb376b.zip |
tidy with new multicave wallets
Diffstat (limited to 'core/views/scans.py')
-rw-r--r-- | core/views/scans.py | 95 |
1 files changed, 52 insertions, 43 deletions
diff --git a/core/views/scans.py b/core/views/scans.py index 4d9f851..7cb0b94 100644 --- a/core/views/scans.py +++ b/core/views/scans.py @@ -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) + # 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 + # # 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" + # 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) - 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) + # 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} ) |