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

Wallets by year and by cave

This commit is contained in:
Philip Sargent
2022-07-31 01:02:02 +03:00
parent 724234949f
commit c1ba6a39a5
7 changed files with 110 additions and 13 deletions

View File

@@ -20,6 +20,9 @@ by looking inside the file before being served.
need to check if inavlid query string is invalid, or produces multiple replies
and render a user-friendly error page.
Note that datewallet(), caveifywallet() etc do NOT save the object to the db. They are ephemeral, just for the page rendering of the
manywallets dict.
'''
def populatewallet(w):
@@ -42,13 +45,13 @@ def populatewallet(w):
def datewallet(w, earliest):
blocks = SurvexBlock.objects.filter(scanswallet = w)
for b in blocks:
if b.date < earliest:
earliest = b.date
for b in blocks:
if b.date:
if b.date < earliest:
earliest = b.date
w.date = earliest
def caveifywallet(w):
print('*')
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
@@ -64,7 +67,38 @@ 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': 'This page logic not implemented yet'})
#return render(request, 'errors/generic.html', {'message': 'This page logic not implemented yet'})
earliest = datetime.datetime.now().date()
manywallets = []
wallets = Wallet.objects.all()
for w in wallets:
if year == w.year():
print(w.year(), w)
manywallets.append(w)
else:
print("NOT WANTED",year, w.year())
continue
wp = w.people()
if not wp: # an -empty list
populatewallet(w)
else:
if len(wp) == 1:
nobody = wp[0].lower()
if nobody == 'unknown' or nobody == 'nobody' or nobody == ' ':
populatewallet(w)
if not w.date():
datewallet(w, earliest)
c = w.cave()
if not c:
caveifywallet(w)
return render(request, 'yearwallets.html', { 'manywallets':manywallets, 'settings': settings, 'year': year})
def cavewallets(request, caveid):
@@ -98,7 +132,6 @@ def cavewallets(request, caveid):
datewallet(w, earliest)
c = w.cave()
if not c:
caveifywallet(w)