diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2023-10-25 01:56:30 +0300 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2023-10-25 01:56:30 +0300 |
commit | 0843a279660b9dd76a68164b60140d0a0e14f39a (patch) | |
tree | 05c407abcddea37b81df9b995d313d3361ff4618 /core/views/scans.py | |
parent | 33477f2b40a5e88379d2d05cfc5356afdbb06269 (diff) | |
download | troggle-0843a279660b9dd76a68164b60140d0a0e14f39a.tar.gz troggle-0843a279660b9dd76a68164b60140d0a0e14f39a.tar.bz2 troggle-0843a279660b9dd76a68164b60140d0a0e14f39a.zip |
Revised (faster, less brain damaged) wallet pages
Diffstat (limited to 'core/views/scans.py')
-rw-r--r-- | core/views/scans.py | 53 |
1 files changed, 19 insertions, 34 deletions
diff --git a/core/views/scans.py b/core/views/scans.py index 0143bea..2494cd9 100644 --- a/core/views/scans.py +++ b/core/views/scans.py @@ -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: |