2020-06-12 18:10:07 +01:00
|
|
|
import datetime
|
|
|
|
import os.path
|
|
|
|
import re
|
2021-03-24 20:38:43 +00:00
|
|
|
from collections import OrderedDict
|
2020-06-12 18:10:07 +01:00
|
|
|
|
|
|
|
import django.db.models
|
|
|
|
from django.db.models import Min, Max
|
2021-03-28 03:48:24 +01:00
|
|
|
from django.shortcuts import render
|
2020-06-12 18:10:07 +01:00
|
|
|
from django.template import Context, loader
|
|
|
|
from django.template.defaultfilters import slugify
|
|
|
|
from django.utils import timezone
|
2020-07-26 20:48:25 +01:00
|
|
|
#from django.views.generic.list import ListView
|
2020-06-12 18:10:07 +01:00
|
|
|
|
2021-04-13 00:43:57 +01:00
|
|
|
from troggle.core.models.troggle import Expedition, Person, PersonExpedition, DataIssue
|
2021-04-13 00:47:17 +01:00
|
|
|
from troggle.core.models.caves import Cave, LogbookEntry
|
2020-06-24 14:10:13 +01:00
|
|
|
from troggle.core.models_survex import SurvexBlock
|
2020-06-12 18:10:07 +01:00
|
|
|
|
|
|
|
import troggle.settings as settings
|
|
|
|
|
|
|
|
|
|
|
|
def pathsreport(request):
|
2021-03-24 20:38:43 +00:00
|
|
|
pathsdict = OrderedDict()
|
2020-07-26 20:48:25 +01:00
|
|
|
try:
|
2021-03-24 20:38:43 +00:00
|
|
|
pathsdict = {
|
|
|
|
# "BOGUS" : str( settings.BOGUS),
|
|
|
|
"JSLIB_URL" : str( settings.JSLIB_URL),
|
2021-04-02 19:22:53 +01:00
|
|
|
"JSLIB_ROOT" : str( settings.JSLIB_ROOT),
|
2021-03-24 20:38:43 +00:00
|
|
|
# "CSSLIB_URL" : str( settings.CSSLIB_URL),
|
|
|
|
"CAVEDESCRIPTIONS" : str( settings.CAVEDESCRIPTIONS),
|
|
|
|
"DIR_ROOT" : str( settings.DIR_ROOT),
|
|
|
|
"ENTRANCEDESCRIPTIONS" : str( settings.ENTRANCEDESCRIPTIONS),
|
|
|
|
"EXPOUSER_EMAIL" : str( settings.EXPOUSER_EMAIL),
|
|
|
|
"EXPOUSERPASS" : str("<redacted>"),
|
|
|
|
"EXPOUSER" : str( settings.EXPOUSER),
|
|
|
|
"EXPOWEB" : str( settings.EXPOWEB),
|
|
|
|
"EXPOWEB_URL" : str( settings.EXPOWEB_URL),
|
|
|
|
"FILES" : str( settings.FILES),
|
|
|
|
"LOGFILE" : str( settings.LOGFILE),
|
|
|
|
"LOGIN_REDIRECT_URL" : str( settings.LOGIN_REDIRECT_URL),
|
|
|
|
"MEDIA_ROOT" : str( settings.MEDIA_ROOT),
|
|
|
|
"MEDIA_URL" : str( settings.MEDIA_URL),
|
|
|
|
"PHOTOS_URL" : str( settings.PHOTOS_URL),
|
|
|
|
"PYTHON_PATH" : str( settings.PYTHON_PATH),
|
|
|
|
"REPOS_ROOT_PATH" : str( settings.REPOS_ROOT_PATH),
|
|
|
|
"ROOT_URLCONF" : str( settings.ROOT_URLCONF),
|
|
|
|
"STATIC_URL" : str( settings.STATIC_URL),
|
|
|
|
"SURVEX_DATA" : str( settings.SURVEX_DATA),
|
|
|
|
"SURVEY_SCANS" : str( settings.SURVEY_SCANS),
|
|
|
|
"SURVEYS" : str( settings.SURVEYS),
|
|
|
|
"SURVEYS_URL" : str( settings.SURVEYS_URL),
|
|
|
|
"SURVEXPORT" : str( settings.SURVEXPORT),
|
|
|
|
"THREEDCACHEDIR" : str( settings.THREEDCACHEDIR),
|
|
|
|
"TUNNEL_DATA" : str( settings.TUNNEL_DATA),
|
|
|
|
"URL_ROOT" : str( settings.URL_ROOT)
|
2020-07-26 20:48:25 +01:00
|
|
|
}
|
|
|
|
except:
|
2021-03-24 21:16:06 +00:00
|
|
|
pathsdict["! EXCEPTION !"] = "missing or exta string constant in troggle/settings"
|
|
|
|
|
|
|
|
pathstype = OrderedDict()
|
|
|
|
try:
|
|
|
|
pathstype = {
|
|
|
|
# "BOGUS" : type(settings.BOGUS),
|
|
|
|
"JSLIB_URL" : type(settings.JSLIB_URL),
|
2021-04-05 14:01:15 +01:00
|
|
|
"JSLIB_ROOT" : type( settings.JSLIB_ROOT),
|
2021-03-24 21:16:06 +00:00
|
|
|
# "CSSLIB_URL" : type(settings.CSSLIB_URL),
|
|
|
|
"CAVEDESCRIPTIONS" : type(settings.CAVEDESCRIPTIONS),
|
|
|
|
"DIR_ROOT" : type(settings.DIR_ROOT),
|
|
|
|
"ENTRANCEDESCRIPTIONS" : type(settings.ENTRANCEDESCRIPTIONS),
|
|
|
|
"EXPOUSER_EMAIL" : type(settings.EXPOUSER_EMAIL),
|
|
|
|
"EXPOUSERPASS" : type(settings.EXPOUSERPASS),
|
|
|
|
"EXPOUSER" : type(settings.EXPOUSER),
|
|
|
|
"EXPOWEB" : type(settings.EXPOWEB),
|
|
|
|
"EXPOWEB_URL" : type(settings.EXPOWEB_URL),
|
|
|
|
"FILES" : type(settings.FILES),
|
|
|
|
"LOGFILE" : type(settings.LOGFILE),
|
|
|
|
"LOGIN_REDIRECT_URL" : type(settings.LOGIN_REDIRECT_URL),
|
|
|
|
"MEDIA_ROOT" : type(settings.MEDIA_ROOT),
|
|
|
|
"MEDIA_URL" : type(settings.MEDIA_URL),
|
|
|
|
"PHOTOS_URL" : type(settings.PHOTOS_URL),
|
|
|
|
"PYTHON_PATH" : type(settings.PYTHON_PATH),
|
|
|
|
"REPOS_ROOT_PATH" : type(settings.REPOS_ROOT_PATH),
|
|
|
|
"ROOT_URLCONF" : type(settings.ROOT_URLCONF),
|
|
|
|
"STATIC_URL" : type(settings.STATIC_URL),
|
|
|
|
"SURVEX_DATA" : type(settings.SURVEX_DATA),
|
|
|
|
"SURVEY_SCANS" : type(settings.SURVEY_SCANS),
|
|
|
|
"SURVEYS" : type(settings.SURVEYS),
|
|
|
|
"SURVEYS_URL" : type(settings.SURVEYS_URL),
|
|
|
|
"SURVEXPORT" : type(settings.SURVEXPORT),
|
|
|
|
"THREEDCACHEDIR" : type(settings.THREEDCACHEDIR),
|
|
|
|
"TUNNEL_DATA" : type(settings.TUNNEL_DATA),
|
|
|
|
"URL_ROOT" : type(settings.URL_ROOT)
|
|
|
|
}
|
|
|
|
except:
|
|
|
|
pathstype["! EXCEPTION !"] = "missing or exta string constant in troggle/settings"
|
2020-07-26 20:48:25 +01:00
|
|
|
|
2020-06-14 10:05:25 +01:00
|
|
|
# settings are unique by paths are not
|
2020-06-12 18:10:07 +01:00
|
|
|
ncodes = len(pathsdict)
|
2021-03-24 20:38:43 +00:00
|
|
|
bycodeslist = sorted(pathsdict.items()) # a list of tuples
|
2021-03-24 21:16:06 +00:00
|
|
|
bycodeslist2 = []
|
|
|
|
|
|
|
|
for k, p in bycodeslist:
|
|
|
|
bycodeslist2.append((k, p, str(pathstype[k])))
|
2020-06-14 10:05:25 +01:00
|
|
|
|
2021-03-24 21:16:06 +00:00
|
|
|
bypaths = sorted(pathsdict.values()) # a list
|
2020-06-14 10:05:25 +01:00
|
|
|
bypathslist = []
|
2021-03-24 20:38:43 +00:00
|
|
|
|
|
|
|
for p in bypaths:
|
|
|
|
for k in pathsdict.keys():
|
|
|
|
if pathsdict[k] == p:
|
2021-03-24 21:16:06 +00:00
|
|
|
bypathslist.append((p, k, str(pathstype[k])))
|
2021-03-24 20:38:43 +00:00
|
|
|
del pathsdict[k]
|
|
|
|
break
|
2020-06-12 18:10:07 +01:00
|
|
|
|
|
|
|
return render(request, 'pathsreport.html', {
|
|
|
|
"pathsdict":pathsdict,
|
2021-03-24 21:16:06 +00:00
|
|
|
"bycodeslist":bycodeslist2,
|
2020-06-12 18:10:07 +01:00
|
|
|
"bypathslist":bypathslist,
|
|
|
|
"ncodes":ncodes})
|
|
|
|
|
|
|
|
def stats(request):
|
|
|
|
statsDict={}
|
|
|
|
statsDict['expoCount'] = "{:,}".format(Expedition.objects.count())
|
|
|
|
statsDict['caveCount'] = "{:,}".format(Cave.objects.count())
|
|
|
|
statsDict['personCount'] = "{:,}".format(Person.objects.count())
|
|
|
|
statsDict['logbookEntryCount'] = "{:,}".format(LogbookEntry.objects.count())
|
|
|
|
|
|
|
|
legsbyexpo = [ ]
|
|
|
|
addupsurvexlength = 0
|
|
|
|
for expedition in Expedition.objects.all():
|
|
|
|
survexblocks = expedition.survexblock_set.all()
|
|
|
|
legsyear=0
|
|
|
|
survexleglength = 0.0
|
|
|
|
for survexblock in survexblocks:
|
2020-07-04 13:31:46 +01:00
|
|
|
survexleglength += survexblock.legslength
|
2020-06-12 18:10:07 +01:00
|
|
|
try:
|
2020-06-16 19:27:32 +01:00
|
|
|
legsyear += int(survexblock.legsall)
|
2020-06-12 18:10:07 +01:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
addupsurvexlength += survexleglength
|
|
|
|
legsbyexpo.append((expedition, {"nsurvexlegs": "{:,}".format(legsyear),
|
|
|
|
"survexleglength":"{:,.0f}".format(survexleglength)}))
|
|
|
|
legsbyexpo.reverse()
|
|
|
|
|
2020-07-04 13:31:46 +01:00
|
|
|
renderDict = {**statsDict, **{ "addupsurvexlength":addupsurvexlength/1000, "legsbyexpo":legsbyexpo }} # new syntax
|
2020-06-12 18:10:07 +01:00
|
|
|
return render(request,'statistics.html', renderDict)
|
2021-04-11 20:00:09 +01:00
|
|
|
|
|
|
|
def dataissues(request):
|
2021-04-12 01:28:54 +01:00
|
|
|
'''Each issue has a parser, a message and a url linking to the offending object after loading
|
|
|
|
'''
|
2021-04-12 01:00:47 +01:00
|
|
|
def myFunc(di):
|
|
|
|
return di.parser.lower() + di.message.lower()
|
|
|
|
|
|
|
|
dilist = list(DataIssue.objects.all())
|
|
|
|
dilist.sort(key = myFunc)
|
2021-04-11 20:00:09 +01:00
|
|
|
|
2021-04-12 01:00:47 +01:00
|
|
|
return render(request,'dataissues.html', {'didict': dilist})
|