summaryrefslogtreecommitdiffstats
path: root/core/views_other.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2020-06-04 21:57:04 +0100
committerPhilip Sargent <philip.sargent@klebos.com>2020-06-04 21:57:04 +0100
commitb7fea2042feb5ad12d99e7279498ad68c00c983b (patch)
treefe871bf7c98c28286b45277e6f432cf3a6aa05ad /core/views_other.py
parentc6d68749e06892ce6607819081e4639a9d589409 (diff)
downloadtroggle-b7fea2042feb5ad12d99e7279498ad68c00c983b.tar.gz
troggle-b7fea2042feb5ad12d99e7279498ad68c00c983b.tar.bz2
troggle-b7fea2042feb5ad12d99e7279498ad68c00c983b.zip
merge exptl & stats, delete millenial & eyecandy
Diffstat (limited to 'core/views_other.py')
-rw-r--r--core/views_other.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/core/views_other.py b/core/views_other.py
index 3da7f82..87cf724 100644
--- a/core/views_other.py
+++ b/core/views_other.py
@@ -11,6 +11,7 @@ from django.template import Context, loader
import databaseReset
from troggle.core.models import Expedition, Person, PersonExpedition
from troggle.core.models_caves import LogbookEntry, QM, Cave, PersonTrip
+from troggle.core.models_survex import SurvexLeg
from troggle.helper import login_required_if_public
@@ -23,7 +24,22 @@ def stats(request):
statsDict['caveCount'] = int(Cave.objects.count())
statsDict['personCount'] = int(Person.objects.count())
statsDict['logbookEntryCount'] = int(LogbookEntry.objects.count())
- return render(request,'statistics.html', statsDict)
+
+ legsbyexpo = [ ]
+ for expedition in Expedition.objects.all():
+ survexblocks = expedition.survexblock_set.all()
+ survexlegs = [ ]
+ survexleglength = 0.0
+ for survexblock in survexblocks:
+ survexlegs.extend(survexblock.survexleg_set.all())
+ survexleglength += survexblock.totalleglength
+ legsbyexpo.append((expedition, {"nsurvexlegs":len(survexlegs), "survexleglength":survexleglength/1000}))
+ legsbyexpo.reverse()
+ survexlegs = SurvexLeg.objects.all()
+ totalsurvexlength = sum([survexleg.tape for survexleg in survexlegs])
+
+ renderDict = {**statsDict, **{ "nsurvexlegs":len(survexlegs), "totalsurvexlength":totalsurvexlength/1000, "legsbyexpo":legsbyexpo }} # new syntax
+ return render(request,'statistics.html', renderDict)
def frontpage(request):
if request.user.is_authenticated():