forked from expo/troggle
find more wallets than we thought we had
This commit is contained in:
parent
11b1d41a55
commit
1971f51b52
@ -11,6 +11,7 @@ from django.http import HttpResponse
|
||||
|
||||
from troggle.core.models.survex import Wallet, SingleScan, SurvexBlock
|
||||
from troggle.core.models.troggle import Person, Expedition
|
||||
from troggle.core.models.troggle import DataIssue
|
||||
from troggle.core.models.caves import GetCaveLookup
|
||||
from troggle.core.views.expo import getmimetype
|
||||
#from troggle.parsers.people import GetPersonExpeditionNameLookup
|
||||
@ -89,7 +90,7 @@ def fillblankpeople(w):
|
||||
# print(f' - {wp=}')
|
||||
nobody = wp[0].lower()
|
||||
if nobody == 'unknown' or nobody == 'nobody' or nobody == ' ' or nobody == '':
|
||||
print(f' - {wp=} {nobody=}')
|
||||
# print(f' - {wp=} {nobody=}')
|
||||
populatewallet(w)
|
||||
|
||||
def fillblankothers(w):
|
||||
@ -100,7 +101,7 @@ def fillblankothers(w):
|
||||
c = w.cave()
|
||||
if not c or c == "":
|
||||
caveifywallet(w)
|
||||
|
||||
|
||||
def fixsurvextick(w, ticks):
|
||||
ticks["S"] = w.fixsurvextick(ticks["S"])
|
||||
|
||||
@ -181,10 +182,27 @@ def cavewallets(request, caveid):
|
||||
else:
|
||||
return render(request,'errors/badslug.html', {'badslug': caveid})
|
||||
|
||||
# remove duplication. SOrting is done in the template
|
||||
wallets = set(Wallet.objects.filter(survexblock__survexfile__cave=cave)) # NB a filtered set
|
||||
manywallets = list(wallets)
|
||||
# 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:
|
||||
zcave = z.cave()
|
||||
if zcave:
|
||||
if str(zcave) in Gcavelookup:
|
||||
fcave = Gcavelookup[str(zcave)]
|
||||
if str(fcave.slug()) == caveid:
|
||||
# print(f' - Found one ! {z.walletname=} {zcave=}')
|
||||
wallets.add(z)
|
||||
else:
|
||||
wurl = f"/scanupload/{z.walletname.replace('#',':')}"
|
||||
print(f' - Unrecognised cave name \'{zcave}\' in {z.walletname}')
|
||||
message = f" ! In {z.walletname} there is an unrecognised cave name '{zcave}'"
|
||||
DataIssue.objects.update_or_create(parser='scans', message=message, url=wurl)
|
||||
|
||||
manywallets = list(set(wallets))
|
||||
for w in manywallets:
|
||||
fillblankpeople(w)
|
||||
fillblankothers(w)
|
||||
@ -205,21 +223,10 @@ def oldwallet(request, path):
|
||||
message = f'Scan folder error or not found \'{path}\' .'
|
||||
return render(request, 'errors/generic.html', {'message': message})
|
||||
|
||||
# def walletindex(request, path):
|
||||
# '''All years: special 'wallet' for *scanned* index pages
|
||||
# '''
|
||||
# print(f'! - walletindex path:{path}')
|
||||
# try:
|
||||
# wallet = Wallet.objects.get(walletname=urlunquote(path))
|
||||
# return render(request, 'walletindex.html', { 'wallet':wallet, 'settings': settings })
|
||||
# except:
|
||||
# message = f'Scan folder (wallet) error or not found \'{path}\' .'
|
||||
# return render(request, 'errors/generic.html', {'message': message})
|
||||
|
||||
def scansingle(request, path, file):
|
||||
'''sends a single binary file to the user for display - browser decides how using mimetype
|
||||
'''
|
||||
|
||||
try:
|
||||
wallet = Wallet.objects.get(walletname=urlunquote(path))
|
||||
singlescan = SingleScan.objects.get(wallet=wallet, name=file)
|
||||
|
Loading…
Reference in New Issue
Block a user