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

more complete list of caves linked to wallets

This commit is contained in:
Philip Sargent 2022-09-22 01:37:25 +03:00
parent 5c0835e076
commit b4cf2bac95
5 changed files with 29 additions and 18 deletions

View File

@ -28,7 +28,7 @@ from troggle.core.models.survex import SurvexStation
from troggle.core.utils import writetrogglefile from troggle.core.utils import writetrogglefile
from troggle.core.utils import TROG from troggle.core.utils import TROG
# Us ethe TROG global object to cache teh cave lookup list # Use the TROG global object to cache the cave lookup list
Gcavelookup = TROG['caves']['gcavelookup'] Gcavelookup = TROG['caves']['gcavelookup']
Gcave_count = TROG['caves']['gcavecount'] Gcave_count = TROG['caves']['gcavecount']

View File

@ -64,13 +64,14 @@ def caveifywallet(w):
'''Gets the cave from the list of survex files, '''Gets the cave from the list of survex files,
only selects one of them though. Only used for display. only selects one of them though. Only used for display.
''' '''
print(f' - Caveify {w=}')
blocknames = [] blocknames = []
blocks = SurvexBlock.objects.filter(scanswallet = w) blocks = SurvexBlock.objects.filter(scanswallet = w)
for b in blocks: for b in blocks:
# NB b.cave is not populated by parser. Use b.survexfile.cave instead, or we could parse b.survexpath # NB b.cave is not populated by parser. Use b.survexfile.cave instead, or we could parse b.survexpath
if b.survexfile.cave: if b.survexfile.cave:
w.cave = b.survexfile.cave # just gets the last one, randomly. SHould make this a list or many:many ideally w.caveobj = b.survexfile.cave # just gets the last one, randomly. SHould make this a list or many:many ideally
w.cave = w.caveobj
if b.name: if b.name:
blocknames.append(b.name) blocknames.append(b.name)
@ -98,9 +99,18 @@ def fillblankothers(w):
if not w.date(): if not w.date():
datewallet(w, earliest) datewallet(w, earliest)
c = w.cave() Gcavelookup = GetCaveLookup()
if not c or c == "":
wcaveid = w.cave()
if not wcaveid or wcaveid == "":
caveifywallet(w) caveifywallet(w)
else:
if wcaveid in Gcavelookup:
w.caveobj = Gcavelookup[wcaveid]
# print(f' - Found cave object from id {wcaveid}')
else:
print(f' - Failed to find cave object from id {wcaveid}')
def fixsurvextick(w, ticks): def fixsurvextick(w, ticks):
ticks["S"] = w.fixsurvextick(ticks["S"]) ticks["S"] = w.fixsurvextick(ticks["S"])
@ -189,17 +199,17 @@ def cavewallets(request, caveid):
# all the ones without a survexblock attached via a *ref, search for match in JSON # all the ones without a survexblock attached via a *ref, search for match in JSON
zilchwallets = set(Wallet.objects.exclude(survexblock__survexfile__cave=cave)) zilchwallets = set(Wallet.objects.exclude(survexblock__survexfile__cave=cave))
for z in zilchwallets: for z in zilchwallets:
zcave = z.cave() zcaveid = z.cave()
if zcave: if zcaveid:
if str(zcave) in Gcavelookup: if str(zcaveid) in Gcavelookup:
fcave = Gcavelookup[str(zcave)] fcave = Gcavelookup[str(zcaveid)]
if str(fcave.slug()) == caveid: if str(fcave.slug()) == caveid:
# print(f' - Found one ! {z.walletname=} {zcave=}') # print(f' - Found one ! {z.walletname=} {zcaveid=}')
wallets.add(z) wallets.add(z)
else: else:
wurl = f"/scanupload/{z.walletname.replace('#',':')}" wurl = f"/scanupload/{z.walletname.replace('#',':')}"
print(f' - Unrecognised cave name \'{zcave}\' in {z.walletname}') print(f' - Unrecognised cave name \'{zcaveid}\' in {z.walletname}')
message = f" ! In {z.walletname} there is an unrecognised cave name '{zcave}'" message = f" ! In {z.walletname} there is an unrecognised cave name '{zcaveid}'"
DataIssue.objects.update_or_create(parser='scans', message=message, url=wurl) DataIssue.objects.update_or_create(parser='scans', message=message, url=wurl)
manywallets = list(set(wallets)) manywallets = list(set(wallets))

View File

@ -30,8 +30,8 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c
<td style="padding:2px">{{wallet.persons}}</td> <td style="padding:2px">{{wallet.persons}}</td>
<td style="padding:2px"> <td style="padding:2px">
{% if wallet.cave %} {% if wallet.cave %}
{% if wallet.cave.slug %} {% if wallet.caveobj.slug %}
<a href="/cave/scans/{{wallet.cave.slug}}">{{wallet.cave}}</a> <a href="/cave/scans/{{wallet.caveobj.slug}}">{{wallet.cave}}</a>
{% else %} {% else %}
{{wallet.cave}} {{wallet.cave}}
{% endif %} {% endif %}

View File

@ -24,12 +24,13 @@
<td style="padding:2px">{% if wallet.date %}{{wallet.date}}{% else %} {% endif %}</td> <td style="padding:2px">{% if wallet.date %}{{wallet.date}}{% else %} {% endif %}</td>
<td style="padding:2px"> <td style="padding:2px">
{% if wallet.cave %} {% if wallet.cave %}
{% if wallet.cave.slug %} {% if wallet.caveobj.slug %}
<a href="/cave/scans/{{wallet.cave.slug}}">{{wallet.cave}}</a> <a href="/cave/scans/{{wallet.caveobj.slug}}">{{wallet.cave}}</a>
{% else %} {% else %}
{{wallet.cave}} {{wallet.cave}}
{% endif %} {% endif %}
{% else %} {% else %}
<em>No wallet.cave {{wallet.cave}}</em>
{% endif %}</td> {% endif %}</td>
<td style="padding:2px">{% if wallet.name %}{{wallet.name}}{% else %}<em>{% if wallet.displaynames %} {% for dn in wallet.displaynames %}{{dn}}{%if not forloop.last %}, {% endif %} {% endfor %}{% else %} {% endif %}</em>{% endif %}</td> <td style="padding:2px">{% if wallet.name %}{{wallet.name}}{% else %}<em>{% if wallet.displaynames %} {% for dn in wallet.displaynames %}{{dn}}{%if not forloop.last %}, {% endif %} {% endfor %}{% else %} {% endif %}</em>{% endif %}</td>
<td style="padding:2px" align=center> <td style="padding:2px" align=center>

View File

@ -40,8 +40,8 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c
<td style="padding:2px">{{wallet.persons}}</td> <td style="padding:2px">{{wallet.persons}}</td>
<td style="padding:2px"> <td style="padding:2px">
{% if wallet.cave %} {% if wallet.cave %}
{% if wallet.cave.slug %} {% if wallet.caveobj.slug %}
<a href="/cave/scans/{{wallet.cave.slug}}">{{wallet.cave}}</a> <a href="/cave/scans/{{wallet.caveobj.slug}}">{{wallet.cave}}</a>
{% else %} {% else %}
{{wallet.cave}} {{wallet.cave}}
{% endif %} {% endif %}