merge exptl & stats, delete millenial & eyecandy

This commit is contained in:
Philip Sargent 2020-06-04 21:57:04 +01:00
parent c6d68749e0
commit b7fea2042f
8 changed files with 50 additions and 83 deletions

View File

@ -128,7 +128,7 @@ class Cave(TroggleModel):
return str("slug:"+self.slug())
def get_QMs(self):
return QM.objects.filter(found_by__cave_slug=self.caveslug_set.all())
return QM.objects.filter(found_by__cave_slug=self.caveslug_set.all())
def new_QM_number(self, year=datetime.date.today().year):
"""Given a cave and the current year, returns the next QM number."""
@ -275,7 +275,7 @@ class Entrance(TroggleModel):
def find_location(self):
r = {'': 'To be entered ',
'?': 'To be confirmed:',
'?': 'To be confirmed:',
'S': '',
'L': 'Lost:',
'R': 'Refindable:'}[self.findability]
@ -566,12 +566,12 @@ class Survey(TroggleModel):
comments = models.TextField(blank=True,null=True)
location = models.CharField(max_length=400,blank=True,null=True) #REDUNDANT
subcave = models.ForeignKey('NewSubCave', blank=True, null=True)
#notes_scan = models.ForeignKey('ScannedImage',related_name='notes_scan',blank=True, null=True) #Replaced by contents field of ScannedImage model
#notes_scan = models.ForeignKey('ScannedImage',related_name='notes_scan',blank=True, null=True) #Replaced by contents field of ScannedImage model
survex_block = models.OneToOneField('SurvexBlock',blank=True, null=True)
logbook_entry = models.ForeignKey('LogbookEntry')
centreline_printed_on = models.DateField(blank=True, null=True)
centreline_printed_by = models.ForeignKey('Person',related_name='centreline_printed_by',blank=True,null=True)
#sketch_scan = models.ForeignKey(ScannedImage,blank=True, null=True) #Replaced by contents field of ScannedImage model
#sketch_scan = models.ForeignKey(ScannedImage,blank=True, null=True) #Replaced by contents field of ScannedImage model
tunnel_file = models.FileField(upload_to='surveyXMLfiles',blank=True, null=True)
tunnel_main_sketch = models.ForeignKey('Survey',blank=True,null=True)
integrated_into_main_sketch_on = models.DateField(blank=True,null=True)

View File

@ -83,10 +83,6 @@ def caveindex(request):
caves1626.sort(key=caveKey)
return render(request,'caveindex.html', {'caves1623': caves1623, 'caves1626': caves1626, 'notablecaves':notablecaves, 'cavepage': True})
def millenialcaves(request):
#RW messing around area
return HttpResponse("Test text", content_type="text/plain")
def cave3d(request, cave_id=''):
cave = getCave(cave_id)
survexfilename = settings.SURVEX_DATA + cave.survex_file

View File

@ -17,7 +17,7 @@ import troggle.parsers.logbooks as logbookparsers
from troggle.core.forms import getTripForm # , get_name, PersonForm
from troggle.core.models import Expedition, Person, PersonExpedition
from troggle.core.models_caves import LogbookEntry, PersonTrip
from troggle.core.models_survex import SurvexBlock, SurvexLeg
from troggle.core.models_survex import SurvexBlock
from troggle.helper import login_required_if_public
from troggle.parsers.logbooks import LoadLogbookForExpedition
from troggle.parsers.people import GetPersonExpeditionNameLookup
@ -217,24 +217,6 @@ def pathsreport(request):
"bypathslist":bypathslist,
"ncodes":ncodes})
def experimental(request):
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])
return render(request, 'experimental.html', { "nsurvexlegs":len(survexlegs), "totalsurvexlength":totalsurvexlength/1000, "legsbyexpo":legsbyexpo })
@login_required_if_public
def newLogbookEntry(request, expeditionyear, pdate = None, pslug = None):
expedition = Expedition.objects.get(year=expeditionyear)

View File

@ -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():

View File

@ -1,26 +0,0 @@
{% extends "base.html" %}
{% load wiki_markup %}
{% load link %}
{% block title %}Experimental{% endblock %}
{% block content %}
<h1>Expo Experimental</h1>
<p>Number of survey legs: {{nsurvexlegs}}, total length: {{totalsurvexlength|stringformat:".3f"}} km</p>
<table>
<tr><th>Year</th><th>Surveys</th><th>Survey Legs</th><th>Total length<br>(km)</th></tr>
{% for legs in legsbyexpo %}
<tr>
<td>{{legs.0.year}}</td>
<td style="text-align:right">{{legs.0.survexblock_set.all|length}}</td>
<td style="text-align:right">{{legs.1.nsurvexlegs|rjust:"10"}}</td>
<td style="text-align:right">{{legs.1.survexleglength|stringformat:".3f"}}</td>
</tr>
{% endfor %}
</table>
{% endblock %}

View File

@ -1,3 +0,0 @@
<img id="richardBanner" class="footer" src="{{ settings.MEDIA_URL }}expoBanner.gif" style="display: none;"/>
<img id="timeMachine" class="footer" src="{{ settings.MEDIA_URL }}timemachine.gif" style="display: none;"/>
<img id="surveyHover" class="footer" src="{{ settings.MEDIA_URL }}surveyHover.gif" style="display: none;"/>

View File

@ -1,8 +1,26 @@
{% extends "base.html" %}
{% load wiki_markup %}
{% load link %}
{% block title %}Database statistics{% endblock %}
{% block title %}Expo statistics{% endblock %}
{% block content %}
Over the course of {{ expoCount }} expeditions, {{ personCount }} people have contributed {{ caveCount }} caves and {{ logbookEntryCount }} logbook entries.
<h1>Expo Statistics</h1>
<p>{{ expoCount }} expeditions: {{ personCount }} people have contributed {{ caveCount }} caves and {{ logbookEntryCount }} logbook entries.
<p>Number of survey legs: {{nsurvexlegs}}, total length: {{totalsurvexlength|stringformat:".3f"}} km</p>
<table>
<tr><th>Year</th><th>Surveys</th><th>Survey Legs</th><th>Total length<br>(km)</th></tr>
{% for legs in legsbyexpo %}
<tr>
<td>{{legs.0.year}}</td>
<td style="text-align:right">{{legs.0.survexblock_set.all|length}}</td>
<td style="text-align:right">{{legs.1.nsurvexlegs|rjust:"10"}}</td>
<td style="text-align:right">{{legs.1.survexleglength|stringformat:".3f"}}</td>
</tr>
{% endfor %}
</table>
{% endblock %}

32
urls.py
View File

@ -12,7 +12,6 @@ from .core.models import *
admin.autodiscover()
# type url probably means it's used.
# HOW DOES THIS WORK:
@ -48,7 +47,6 @@ actualurlpatterns = patterns('',
url(r'^getPeople/(?P<expeditionslug>.*)', views_logbooks.get_people, name = "get_people"),
url(r'^getLogBookEntries/(?P<expeditionslug>.*)', views_logbooks.get_logbook_entries, name = "get_logbook_entries"),
url(r'^cave/new/$', views_caves.edit_cave, name="newcave"),
url(r'^cave/(?P<cave_id>[^/]+)/?$', views_caves.cave, name="cave"),
url(r'^caveslug/([^/]+)/?$', views_caves.caveSlug, name="caveSlug"),
@ -70,16 +68,14 @@ actualurlpatterns = patterns('',
url(r'^cave/(?P<slug>[^/]+)/edit/$', views_caves.edit_cave, name="edit_cave"),
#(r'^cavesearch', caveSearch),
url(r'^cave/(?P<cave_id>[^/]+)/(?P<year>\d\d\d\d)-(?P<qm_id>\d*)(?P<grade>[ABCDX]?)?$', views_caves.qm, name="qm"),
url(r'^prospecting_guide/$', views_caves.prospecting),
url(r'^logbooksearch/(.*)/?$', views_logbooks.logbookSearch),
url(r'^statistics/?$', views_other.stats, name="stats"),
url(r'^survey/?$', surveyindex, name="survey"),
url(r'^survey/(?P<year>\d\d\d\d)\#(?P<wallet_number>\d*)$', survey, name="survey"),
@ -89,21 +85,17 @@ actualurlpatterns = patterns('',
url(r'^logbook/?$',views_other.downloadLogbook, name="downloadlogbook"),
url(r'^cave/(?P<cave_id>[^/]+)/qm\.csv/?$', views_other.downloadQMs, name="downloadqms"),
(r'^downloadqms$', views_other.downloadQMs),
url(r'^eyecandy$', views_other.eyecandy),
(r'^admin/doc/?', include('django.contrib.admindocs.urls')),
#url(r'^admin/(.*)', admin.site.get_urls, name="admin"),
(r'^admin/', include(admin.site.urls)),
# don't know why this needs troggle/ in here. nice to get it out
url(r'^troggle/media-admin/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ADMIN_DIR, 'show_indexes':True}),
(r'^accounts/', include('registration.backends.default.urls')),
(r'^profiles/', include('profiles.urls')),
# (r'^personform/(.*)$', personForm),
(r'^expofiles/(?P<path>.*)$', 'django.views.static.serve',
@ -121,45 +113,37 @@ actualurlpatterns = patterns('',
url(r'^survexfile/(?P<survex_file>.*?)\.3d$', views_survex.threed, name="threed"),
url(r'^survexfile/(?P<survex_file>.*?)\.log$', views_survex.svxraw),
url(r'^survexfile/(?P<survex_file>.*?)\.err$', views_survex.err),
url(r'^survexfile/caves/$', views_survex.survexcaveslist, name="survexcaveslist"),
url(r'^survexfile/(?P<survex_cave>.*)$', views_survex.survexcavesingle, name="survexcavessingle"),
url(r'^survexfileraw/(?P<survex_file>.*?)\.svx$', views_survex.svxraw, name="svxraw"),
(r'^survey_files/listdir/(?P<path>.*)$', view_surveys.listdir),
(r'^survey_files/download/(?P<path>.*)$', view_surveys.download),
#(r'^survey_files/upload/(?P<path>.*)$', view_surveys.upload),
#(r'^survey_scans/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.SURVEY_SCANS, 'show_indexes':True}),
url(r'^survey_scans/$', view_surveys.surveyscansfolders, name="surveyscansfolders"),
url(r'^survey_scans/(?P<path>[^/]+)/$', view_surveys.surveyscansfolder, name="surveyscansfolder"),
url(r'^survey_scans/(?P<path>[^/]+)/(?P<file>[^/]+(?:png|jpg|jpeg))$',
view_surveys.surveyscansingle, name="surveyscansingle"),
url(r'^tunneldata/$', view_surveys.tunneldata, name="tunneldata"),
url(r'^tunneldataraw/(?P<path>.+?\.xml)$', view_surveys.tunnelfile, name="tunnelfile"),
url(r'^tunneldataraw/(?P<path>.+?\.xml)/upload$',view_surveys.tunnelfileupload, name="tunnelfileupload"),
#url(r'^tunneldatainfo/(?P<path>.+?\.xml)$', view_surveys.tunnelfileinfo, name="tunnelfileinfo"),
#(r'^photos/(?P<path>.*)$', 'django.views.static.serve',
#{'document_root': settings.PHOTOS_ROOT, 'show_indexes':True}),
url(r'^prospecting/(?P<name>[^.]+).png$', prospecting_image, name="prospecting_image"),
# (r'^gallery/(?P<path>.*)$', 'django.views.static.serve',
# {'document_root': settings.PHOTOS_ROOT, 'show_indexes':True}),
# for those silly ideas
url(r'^experimental.*$', views_logbooks.experimental, name="experimental"),
url(r'^pathsreport.*$', views_logbooks.pathsreport, name="pathsreport"),
#url(r'^trip_report/?$',views_other.tripreport,name="trip_report")
url(r'^(.*)_edit$', 'flatpages.views.editflatpage', name="editflatpage"),
url(r'^(.*)$', 'flatpages.views.flatpage', name="flatpage"),
)