From b7fea2042feb5ad12d99e7279498ad68c00c983b Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Thu, 4 Jun 2020 21:57:04 +0100 Subject: [PATCH] merge exptl & stats, delete millenial & eyecandy --- core/models_caves.py | 8 ++++---- core/views_caves.py | 4 ---- core/views_logbooks.py | 20 +------------------- core/views_other.py | 18 +++++++++++++++++- templates/experimental.html | 26 -------------------------- templates/eyecandy.html | 3 --- templates/statistics.html | 22 ++++++++++++++++++++-- urls.py | 32 ++++++++------------------------ 8 files changed, 50 insertions(+), 83 deletions(-) delete mode 100644 templates/experimental.html delete mode 100644 templates/eyecandy.html diff --git a/core/models_caves.py b/core/models_caves.py index eaad454..0d35583 100644 --- a/core/models_caves.py +++ b/core/models_caves.py @@ -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) diff --git a/core/views_caves.py b/core/views_caves.py index 432eef9..d9d6682 100644 --- a/core/views_caves.py +++ b/core/views_caves.py @@ -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 diff --git a/core/views_logbooks.py b/core/views_logbooks.py index 53333fb..b430796 100644 --- a/core/views_logbooks.py +++ b/core/views_logbooks.py @@ -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) 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(): diff --git a/templates/experimental.html b/templates/experimental.html deleted file mode 100644 index 17d96ef..0000000 --- a/templates/experimental.html +++ /dev/null @@ -1,26 +0,0 @@ -{% extends "base.html" %} -{% load wiki_markup %} -{% load link %} - -{% block title %}Experimental{% endblock %} - -{% block content %} - -

Expo Experimental

- -

Number of survey legs: {{nsurvexlegs}}, total length: {{totalsurvexlength|stringformat:".3f"}} km

- - - -{% for legs in legsbyexpo %} - - - - - - -{% endfor %} -
YearSurveysSurvey LegsTotal length
(km)
{{legs.0.year}}{{legs.0.survexblock_set.all|length}}{{legs.1.nsurvexlegs|rjust:"10"}}{{legs.1.survexleglength|stringformat:".3f"}}
- -{% endblock %} - diff --git a/templates/eyecandy.html b/templates/eyecandy.html deleted file mode 100644 index 1e8def6..0000000 --- a/templates/eyecandy.html +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/templates/statistics.html b/templates/statistics.html index daca752..5c9810b 100644 --- a/templates/statistics.html +++ b/templates/statistics.html @@ -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. +

Expo Statistics

+ +

{{ expoCount }} expeditions: {{ personCount }} people have contributed {{ caveCount }} caves and {{ logbookEntryCount }} logbook entries. + +

Number of survey legs: {{nsurvexlegs}}, total length: {{totalsurvexlength|stringformat:".3f"}} km

+ + + +{% for legs in legsbyexpo %} + + + + + + +{% endfor %} +
YearSurveysSurvey LegsTotal length
(km)
{{legs.0.year}}{{legs.0.survexblock_set.all|length}}{{legs.1.nsurvexlegs|rjust:"10"}}{{legs.1.survexleglength|stringformat:".3f"}}
+ {% endblock %} \ No newline at end of file diff --git a/urls.py b/urls.py index cf7047f..0044633 100644 --- a/urls.py +++ b/urls.py @@ -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.*)', views_logbooks.get_people, name = "get_people"), url(r'^getLogBookEntries/(?P.*)', views_logbooks.get_logbook_entries, name = "get_logbook_entries"), - url(r'^cave/new/$', views_caves.edit_cave, name="newcave"), url(r'^cave/(?P[^/]+)/?$', views_caves.cave, name="cave"), url(r'^caveslug/([^/]+)/?$', views_caves.caveSlug, name="caveSlug"), @@ -70,16 +68,14 @@ actualurlpatterns = patterns('', url(r'^cave/(?P[^/]+)/edit/$', views_caves.edit_cave, name="edit_cave"), #(r'^cavesearch', caveSearch), - url(r'^cave/(?P[^/]+)/(?P\d\d\d\d)-(?P\d*)(?P[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\d\d\d\d)\#(?P\d*)$', survey, name="survey"), @@ -89,21 +85,17 @@ actualurlpatterns = patterns('', url(r'^logbook/?$',views_other.downloadLogbook, name="downloadlogbook"), url(r'^cave/(?P[^/]+)/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.*)$', '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.*)$', 'django.views.static.serve', @@ -121,45 +113,37 @@ actualurlpatterns = patterns('', url(r'^survexfile/(?P.*?)\.3d$', views_survex.threed, name="threed"), url(r'^survexfile/(?P.*?)\.log$', views_survex.svxraw), url(r'^survexfile/(?P.*?)\.err$', views_survex.err), - - + url(r'^survexfile/caves/$', views_survex.survexcaveslist, name="survexcaveslist"), url(r'^survexfile/(?P.*)$', views_survex.survexcavesingle, name="survexcavessingle"), url(r'^survexfileraw/(?P.*?)\.svx$', views_survex.svxraw, name="svxraw"), - - + (r'^survey_files/listdir/(?P.*)$', view_surveys.listdir), (r'^survey_files/download/(?P.*)$', view_surveys.download), #(r'^survey_files/upload/(?P.*)$', view_surveys.upload), - - #(r'^survey_scans/(?P.*)$', '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[^/]+)/$', view_surveys.surveyscansfolder, name="surveyscansfolder"), url(r'^survey_scans/(?P[^/]+)/(?P[^/]+(?:png|jpg|jpeg))$', view_surveys.surveyscansingle, name="surveyscansingle"), - + url(r'^tunneldata/$', view_surveys.tunneldata, name="tunneldata"), url(r'^tunneldataraw/(?P.+?\.xml)$', view_surveys.tunnelfile, name="tunnelfile"), url(r'^tunneldataraw/(?P.+?\.xml)/upload$',view_surveys.tunnelfileupload, name="tunnelfileupload"), - + #url(r'^tunneldatainfo/(?P.+?\.xml)$', view_surveys.tunnelfileinfo, name="tunnelfileinfo"), - + #(r'^photos/(?P.*)$', 'django.views.static.serve', #{'document_root': settings.PHOTOS_ROOT, 'show_indexes':True}), - + url(r'^prospecting/(?P[^.]+).png$', prospecting_image, name="prospecting_image"), # (r'^gallery/(?P.*)$', '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"), )