2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2026-01-19 00:02:56 +00:00

add survey by year to wallets for each cave: Charlotte's request

This commit is contained in:
2025-09-26 20:38:18 +03:00
parent 1370524479
commit 400fd8430e
4 changed files with 24 additions and 3 deletions

View File

@@ -246,6 +246,12 @@ class SurvexBlock(models.Model):
def isSurvexBlock(self): # Function used in templates
return True
def year(self):
if self.date:
return self.date.year
else:
return 1970
def DayIndex(self):
"""This is used to set different colours for the different trips on

View File

@@ -1,4 +1,5 @@
import datetime
from collections import defaultdict
from pathlib import Path
from urllib.parse import unquote as urlunquote
@@ -327,14 +328,25 @@ def cavewallets(request, caveid):
expeditions = Expedition.objects.all()
length_ug = 0.0
length_by_year = defaultdict(int) # initialises values to zero
checksum = 0
for w in manywallets:
for sb in w.survexblock_set.all():
length_ug += sb.legslength
length_by_year[sb.year()] += sb.legslength
length_by_year = dict(sorted(length_by_year.items()))
for y in length_by_year:
checksum += length_by_year[y]
print(f"{y} {length_by_year[y]:.0f}")
for key in list(length_by_year.keys()):
if length_by_year[key] < 0.1:
del length_by_year[key]
return render(
request,
"cavewallets.html",
{"manywallets": manywallets, "settings": settings, "cave": cave, "expeditions": expeditions,
"length_ug": length_ug, "year": current_expo()}
"length_ug": length_ug, "length_by_year": length_by_year, "checksum": checksum, "year": current_expo()}
)

View File

@@ -25,7 +25,11 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c
<br />
<p>Total underground survey length: {{length_ug|floatformat:"1g"}} m<br />
{% for year, length in length_by_year.items %}
{{ year }} {{ length|floatformat:"0g" }} m</br>
{% endfor %}
<p>Total underground survey length: {{length_ug|floatformat:"1g"}} m (checksum: {{length_ug|floatformat:"1g"}} )<br />
Note that this is for <em>all the wallets</em> listed above, which includes those which are surveys of different caves not just {{cave}}.
<br />
If you want accurate cave lengths for {{cave}}, go to the <a href="/survexfile/{{cave.survex_file}}">primary survex file</a> for this cave

View File

@@ -62,5 +62,4 @@ which is probably more useful.
<p>Note that names in italics are copied from the related survex file block name.<br />
Note also that survex data recently uploaded will not appear in this table until a database reset is done on the server.
<p>Note that all the Tunneled/Therioned boxes are fuchsia pending a proper method of setting this.