mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-03-31 23:34:00 +01:00
add survey by year to wallets for each cave: Charlotte's request
This commit is contained in:
@@ -246,6 +246,12 @@ class SurvexBlock(models.Model):
|
|||||||
|
|
||||||
def isSurvexBlock(self): # Function used in templates
|
def isSurvexBlock(self): # Function used in templates
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def year(self):
|
||||||
|
if self.date:
|
||||||
|
return self.date.year
|
||||||
|
else:
|
||||||
|
return 1970
|
||||||
|
|
||||||
def DayIndex(self):
|
def DayIndex(self):
|
||||||
"""This is used to set different colours for the different trips on
|
"""This is used to set different colours for the different trips on
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
from collections import defaultdict
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from urllib.parse import unquote as urlunquote
|
from urllib.parse import unquote as urlunquote
|
||||||
|
|
||||||
@@ -327,14 +328,25 @@ def cavewallets(request, caveid):
|
|||||||
|
|
||||||
expeditions = Expedition.objects.all()
|
expeditions = Expedition.objects.all()
|
||||||
length_ug = 0.0
|
length_ug = 0.0
|
||||||
|
length_by_year = defaultdict(int) # initialises values to zero
|
||||||
|
checksum = 0
|
||||||
for w in manywallets:
|
for w in manywallets:
|
||||||
for sb in w.survexblock_set.all():
|
for sb in w.survexblock_set.all():
|
||||||
length_ug += sb.legslength
|
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(
|
return render(
|
||||||
request,
|
request,
|
||||||
"cavewallets.html",
|
"cavewallets.html",
|
||||||
{"manywallets": manywallets, "settings": settings, "cave": cave, "expeditions": expeditions,
|
{"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()}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,11 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c
|
|||||||
|
|
||||||
|
|
||||||
<br />
|
<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}}.
|
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 />
|
<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
|
If you want accurate cave lengths for {{cave}}, go to the <a href="/survexfile/{{cave.survex_file}}">primary survex file</a> for this cave
|
||||||
|
|||||||
@@ -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 />
|
<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.
|
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.
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user