summaryrefslogtreecommitdiffstats
path: root/core/views_other.py
diff options
context:
space:
mode:
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():