diff --git a/core/views_survex.py b/core/views_survex.py index 31b9583..89831e1 100644 --- a/core/views_survex.py +++ b/core/views_survex.py @@ -368,8 +368,8 @@ def survexcaveslist(request): lsurvdirobj = [ ] for lsubsvx in dsubsvx: lsurvdirobj.append(("caves-1623/"+cavedir+"/"+subdir+"/"+lsubsvx, lsubsvx)) - if len(dsubsvx) > 1: - subsurvdirs.append((lsurvdirobj[0], lsurvdirobj[1:])) + if len(dsubsvx) >= 1: + subsurvdirs.append((subdir,lsurvdirobj[0], lsurvdirobj[0:])) # list now includes the first item too subdircaves.append((cavedir, (survdirobj[0], survdirobj[1:]), subsurvdirs)) # multifile caves @@ -381,27 +381,31 @@ def survexcaveslist(request): return render_to_response('svxfilecavelist.html', {'settings': settings, "onefilecaves":onefilecaves, "multifilecaves":multifilecaves, "subdircaves":subdircaves }) - -# parsing all the survex files of a single cave and showing that it's consistent and can find all the files and people - -# currently not showing Explorers or Titles. link test from SurvexFile page is "dates and explorers" -# Should explicity fix the kataster number thing. def survexcavesingle(request, survex_cave): - print(">>>", survex_cave) + '''parsing all the survex files of a single cave and showing that it's consistent and can find all + the files and people. Currently not showing Explorers or Titles. link test from SurvexFile page + is "dates and explorers". Should explicity fix the kataster number thing. + ''' + sc = survex_cave breload = False if breload: - parsers.survex.ReloadSurvexCave(survex_cave) # does not exit now, needs re-writing to work. + parsers.survex.ReloadSurvexCave(sc) # does not exit now, needs re-writing to work. try: - cave = Cave.objects.get(kataster_number=survex_cave) - for survexdirectory in cave.survexdirectory_set.all: - print(">>> >>>", survexdirectory, flush=True) + cave = Cave.objects.get(kataster_number=sc) return render_to_response('svxcavesingle.html', {'settings': settings, "cave":cave }) except ObjectDoesNotExist: # can get here if the survex file is in a directory labelled with unofficial number not kataster number. - cave = Cave.objects.get(unofficial_number=survex_cave) - return render_to_response('svxcavesingle.html', {'settings': settings, "cave":cave }) - # should produce useful error message for person trying to upload or manage survex files + # maybe - and _ mixed up, or CUCC-2017- instead of 2017-CUCC-, or CUCC2015DL01 ?? + for unoff in [sc, sc.replace('-','_'), sc.replace('_','-')]: + try: + cave = Cave.objects.get(unofficial_number=unoff) + return render_to_response('svxcavesingle.html', {'settings': settings, "cave":cave }) + except ObjectDoesNotExist: + continue + return render_to_response('svxcavesingle404.html', {'settings': settings, "cave":sc }) + except: - raise Http404() + return render_to_response('svxcavesingle404.html', {'settings': settings, "cave":sc }) + diff --git a/templates/svxcavesingle404.html b/templates/svxcavesingle404.html new file mode 100644 index 0000000..7409785 --- /dev/null +++ b/templates/svxcavesingle404.html @@ -0,0 +1,83 @@ +{% extends "base.html" %} +{% load wiki_markup %} +{% load link %} + +{% block title %}List of survex files{% endblock %} + +{% block content %} + +

Surveys for cave - Cave not found

+ +

Cave number looked for: '{{cave}}'

+

kataster number like this not found

+

unofficial number like this not found

+ +

+{% for survexdirectory in cave.survexdirectory_set.all %} + {{survexdirectory.path}} +{% endfor %} +

+ +{% for survexdirectory in cave.survexdirectory_set.all %} +

{{survexdirectory.path}}

+ + + + +{% for survexfile in survexdirectory.survexfile_set.all %} + + {% if survexfile.exists %} + + + +{% for survexblock in survexfile.survexblock_set.all %} + + + + + + + + + + + + +{% endfor %} +{% endfor %} +
Survex fileBlockDateExplorerslengthTitlesScans
+ {% else %} + + {% endif %} + + {% ifequal survexfile survexdirectory.primarysurvexfile %} + {{survexfile.path}} + {% else %} + {{survexfile.path}} + {% endifequal %} +
{{survexblock.name}} + {% if survexblock.expedition %} + {{survexblock.date|date:"D d M Y"}} + {% else %} + + {% endif %} + + {% for personrole in survexblock.survexpersonrole_set.all %} + {% if personrole.personexpedition %} + {{personrole.personname}} + {% else %} + {{personrole.personname}} + {% endif %} + {% endfor %} + {{survexblock.legslength|stringformat:".1f"}} + {{survexblock.title}} + + {% if survexblock.scansfolder %} + {{survexblock.scansfolder.walletname}} + {% endif %} +
+ +{% endfor %} + +{% endblock %} + diff --git a/templates/svxfilecavelist.html b/templates/svxfilecavelist.html index 59f177f..f148b07 100644 --- a/templates/svxfilecavelist.html +++ b/templates/svxfilecavelist.html @@ -23,9 +23,9 @@ -{% for primarycavefile, subcavefiles in subsurvdirs %} +{% for name, primarycavefile, subcavefiles in subsurvdirs %} - {{primarycavefile.1}} + {{name}} {% for cavepath, cavename in subcavefiles %} {{cavename}} diff --git a/urls.py b/urls.py index ebc73d2..ba5a67e 100644 --- a/urls.py +++ b/urls.py @@ -7,7 +7,7 @@ from django.contrib import admin from django.urls import reverse, resolve from troggle.core import views_other, views_caves, views_logbooks, views_statistics, views_survex, view_surveys -#from troggle.core.views_other import logbook_entry_suggestions +from troggle.core.views_other import troggle404 from troggle.core.views_caves import ent, prospecting_image from troggle.core.views_statistics import pathsreport, stats from flatpages import views as flatviews @@ -25,6 +25,7 @@ which is vital to writing code for the webapp. So the URL dispatch is declarativ The API urls return TSV or JSON and are new in July 2020. """ +#handler404 = 'troggle.core.views_other.troggle404' # can't get this to work. but 404.html is default anyway # Many of these patterns do not work because troggle spent many years broken and we have # not yet restored all the functions. Some may have never been fully implemented in @@ -102,7 +103,7 @@ actualurlpatterns = [ 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/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"), @@ -146,6 +147,7 @@ actualurlpatterns = [ urlpatterns = [ url('^%s' % settings.DIR_ROOT, include(actualurlpatterns)) ] + # When apache is running these prempt Django so Django never sees them. # NEW apache configurations suggested as of 20 March 2021: