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

Revised (faster, less brain damaged) wallet pages

This commit is contained in:
2023-10-25 01:56:30 +03:00
parent 33477f2b40
commit 0843a27966
8 changed files with 151 additions and 92 deletions

View File

@@ -27,28 +27,26 @@ Note that caveifywallet() etc do NOT save the object to the db. They are ephemer
manywallets dict.
TODO
cave for a wallet - just gets the last one, randomly. SHould make this a list or many:many ideally
-- add the participants on an explicit wallet list to .slugpeople so that they get proper URL-linked
on the per-person wallet report, and do the same thing for per-cave and per-year wallet reports
add this file in to the todo list thinggy.
"""
def fix_manywallets(many):
for w in many:
fillblankpeople(w)
fillblankothers(w)
w.ticks = w.get_ticks() # the complaints in colour form
fixsurvextick(w, w.ticks)
def populatewallet(w):
"""Copy survex data here just for display, not permanently
"""Need to tidy this up, now all the work is done at parse time not here
Only gets data from the survex file when it was parsed on import, or edited (& thus parsed) online,
so doesn't work if there was no *ref value
"""
slugpeople = set()
blocks = SurvexBlock.objects.filter(scanswallet=w)
for b in blocks:
for personrole in b.survexpersonrole_set.all():
slugpeople.add(personrole.person) # Person objects, not the names anymore
w.slugpeople = slugpeople
w.slugpeople = w.persons.all()
def caveifywallet(w):
@@ -104,10 +102,10 @@ def fillblankpeople(w):
if nobody(wp):
populatewallet(w) # sets w.slugpeople
else:
w.persons = parse_name_list(w)
w.peeps = parse_name_list(w)
populatewallet(w) # sets w.slugpeople
if hasattr(w, "slugpeople"):
w.persons = w.persons.difference(w.slugpeople)
w.peeps = w.peeps.difference(w.slugpeople)
return
@@ -243,11 +241,7 @@ def walletslistperson(request, slug):
print(message)
DataIssue.objects.update_or_create(parser="wallets", message=message, url=wurl)
for w in manywallets:
fillblankpeople(w)
fillblankothers(w)
w.ticks = w.get_ticks() # the complaints in colour form
fixsurvextick(w, w.ticks)
fix_manywallets(manywallets)
return manywallets
# print("-walletslistperson")
@@ -257,6 +251,7 @@ def walletslistperson(request, slug):
expeditions = Expedition.objects.all()
length_ug = 0.0
for w in manywallets:
print(w.persons)
for sb in w.survexblock_set.all():
length_ug += sb.legslength
return render(
@@ -284,25 +279,18 @@ def walletslistyear(request, year):
def ticksyearwallet(year):
manywallets = []
wallets = Wallet.objects.filter(walletyear__year=year)
for w in wallets:
manywallets.append(w)
fillblankpeople(w)
fillblankothers(w)
w.ticks = w.get_ticks() # the complaints in colour form, from the json file on disc
fixsurvextick(w, w.ticks)
manywallets = Wallet.objects.filter(walletyear__year=year)
fix_manywallets(manywallets)
return manywallets
# print("-walletslistyear")
if year < 1976 or year > 2050:
return render(request, "errors/generic.html", {"message": "Year out of range. Must be between 1976 and 2050"})
# return render(request, 'errors/generic.html', {'message': 'This page logic not implemented yet'})
year = str(year)
manywallets = ticksyearwallet(year)
expeditions = Expedition.objects.all() #bad Django style
expeditions = Expedition.objects.all()
expedition = expeditions.filter(year=year)
length_ug = 0.0
for w in manywallets:
@@ -334,11 +322,8 @@ def cavewallets(request, caveid):
wallets = cave.wallets.all()
manywallets = list(set(wallets))
for w in manywallets:
fillblankpeople(w)
fillblankothers(w)
w.ticks = w.get_ticks() # the complaints in colour form, from the json file on disc
fixsurvextick(w, w.ticks)
fix_manywallets(manywallets)
expeditions = Expedition.objects.all()
length_ug = 0.0
for w in manywallets: