diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2023-10-23 03:24:34 +0300 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2023-10-23 03:24:34 +0300 |
commit | 2b960865351ff8841c098a5e559847a2f4f909d4 (patch) | |
tree | d6201347713004a7888ebbe6750fa8065f79db9e /core/views/scans.py | |
parent | 54ffab3e93a8d3f0b3d253037eb57a7fb78012d5 (diff) | |
download | troggle-2b960865351ff8841c098a5e559847a2f4f909d4.tar.gz troggle-2b960865351ff8841c098a5e559847a2f4f909d4.tar.bz2 troggle-2b960865351ff8841c098a5e559847a2f4f909d4.zip |
caves->wallets at parse time
Diffstat (limited to 'core/views/scans.py')
-rw-r--r-- | core/views/scans.py | 52 |
1 files changed, 4 insertions, 48 deletions
diff --git a/core/views/scans.py b/core/views/scans.py index 7cb0b94..fbd5369 100644 --- a/core/views/scans.py +++ b/core/views/scans.py @@ -53,14 +53,15 @@ def populatewallet(w): def caveifywallet(w): """Gets the caves from the list of survex files, + If called from survex parser, we never need to call it from a view too. """ # print(f' - Caveify {w=}') blocknames = [] blocks = SurvexBlock.objects.filter(scanswallet=w) for b in blocks: # NB b.cave is not populated by parser. Use b.survexfile.cave instead, or we could parse b.survexpath - if b.survexfile.cave: - w.caves.add(b.survexfile.cave) + #if b.survexfile.cave: + #w.caves.add(b.survexfile.cave) if b.name: blocknames.append(b.name) @@ -337,52 +338,7 @@ def cavewallets(request, caveid): else: return render(request, "errors/badslug.html", {"badslug": f"{caveid} - from cavewallets()"}) - # 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)) - - # 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() # 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" - # # 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)) @@ -447,5 +403,5 @@ def allscans(request): # manywallets = Wallet.objects.all().prefetch_related('singlescan') fails as the link is defined on 'singlescan' not on 'wallet' expeditions = Expedition.objects.all() return render( - request, "manywallets.html", {"manywallets": manywallets, "settings": settings, "expeditions": expeditions} + request, "walletsall.html", {"manywallets": manywallets, "settings": settings, "expeditions": expeditions} ) |