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 %} + +
+{% for survexdirectory in cave.survexdirectory_set.all %} + {{survexdirectory.path}} +{% endfor %} +
+ +{% for survexdirectory in cave.survexdirectory_set.all %} +Survex file | Block | Date | Explorers | length | Titles | Scans |
---|---|---|---|---|---|---|
+ {% 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 %} + | +