2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-15 07:47:13 +00:00

Extend wallets by cave report

This commit is contained in:
Philip Sargent
2022-07-28 01:48:22 +03:00
parent dd0fcc28dd
commit fea69c0371
9 changed files with 84 additions and 44 deletions

View File

@@ -29,16 +29,23 @@ def walletslistyear(request, year):
return render(request, 'errors/generic.html', {'message': 'Year out of range. Must be between 1976 and 2050'})
else:
year = str(year)
return render(request, 'errors/generic.html', {'message': 'not implemented yet'})
return render(request, 'errors/generic.html', {'message': 'This page logic not implemented yet'})
def walletslistcave(request, caveid):
'''Page which displays a list of all the wallets attached to a specific cave, e.g. '1623-204'
def cavewallets(request, caveid):
'''Returns all the wallets for just one cave
'''
g = GetCaveLookup()
if caveid not in g:
return render(request, 'errors/generic.html', {'message': f'Cave identifier not recognised:"{caveid}"'})
return render(request, 'errors/generic.html', {'message': 'not implemented yet'})
Gcavelookup = GetCaveLookup()
if caveid in Gcavelookup:
cave = Gcavelookup[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)
return render(request, 'cavewallets.html', { 'manywallets':manywallets, 'settings': settings, 'cave': cave})
def oldwallet(request, path):
'''Now called only for non-standard wallet structures for pre-2000 wallets
@@ -84,22 +91,7 @@ def allscans(request):
to get the related singlescan and survexblock objects but that requires rewriting this to do the query on those, not on
the wallets
'''
manywallets = Wallet.objects.all()
manywallets = Wallet.objects.all() # NB all of them
# manywallets = Wallet.objects.all().prefetch_related('singlescan') fails as the link is defined on 'singlescan' not on 'wallet'
return render(request, 'manywallets.html', { 'manywallets':manywallets, 'settings': settings })
def cavewallets(request, cave_id):
'''Returns all the wallets for just one cave,
'''
Gcavelookup = GetCaveLookup()
if cave_id in Gcavelookup:
cave = Gcavelookup[cave_id]
else:
return render(request,'errors/badslug.html', {'badslug': cave_id})
# remove duplication. SOrting is done in the template
wallets = set(Wallet.objects.filter(survexblock__survexfile__cave=cave))
manywallets = list(wallets)
return render(request, 'cavewallets.html', { 'manywallets':manywallets, 'settings': settings, 'cave': cave})