diff --git a/core/views/caves.py b/core/views/caves.py index 09e1f7d..a002a0e 100644 --- a/core/views/caves.py +++ b/core/views/caves.py @@ -297,14 +297,14 @@ def rendercave(request, cave, slug, cave_id=""): return r -def cavepage(request, karea, subpath): +def cavepage(request, karea=None, subpath=None, slug=None): """Displays a cave description page accessed by kataster area number specifically OR accessed by cave.url specifically set in data, e.g. "1623/000/000" <= cave-data/1623-000.html "1623/41/115.htm" <= cave-data/1623-115.html - so we have to query the database to fine the URL as we cannot rely on the url actually telling us the cave by inspection. + so we have to query the database to find the URL as we cannot rely on the url actually telling us the cave by inspection. NOTE that old caves have ".html" (or ".htm") in the URL as they used to be actual files. But since 2006 these URLs refer to virtual pages generated on the fly by troggle, so the".html" is confusing and redundant. @@ -312,9 +312,17 @@ def cavepage(request, karea, subpath): There are also A LOT OF URLS to e.g. /1623/161/l/rl89a.htm which are IMAGES and real html files in cave descriptions. These need to be handled HERE too (accident of history). """ + if slug: + Gcavelookup = GetCaveLookup() + if slug in Gcavelookup: + cave = Gcavelookup[slug] + return rendercave(request, cave, slug) + else: + message = f"Failed to find cave from identifier given: {slug}." + return render(request, "errors/generic.html", {"message": message}) + kpath = karea + subpath # print(f" ! cavepage:'{kpath}' kataster area:'{karea}' rest of path:'{subpath}'") - try: cave = Cave.objects.get(url=kpath) # ideally this will be unique except Cave.DoesNotExist: diff --git a/templates/survexdir.html b/templates/survexdir.html index e2e2747..4b4fe11 100644 --- a/templates/survexdir.html +++ b/templates/survexdir.html @@ -4,29 +4,17 @@ {% block content %} {% autoescape off %} -
Dir Path | Primary svx |
---|---|
{{sd.path}} | -{{sd.primarysurvexfile}}.svx | -
Cave | f.survexdirectory.path | f.primary.path.parent() | f.primary | f.path | |||
---|---|---|---|---|---|---|---|
Cave | Cave primary | f.primary | f.path | ||||
{{f.cave}} | -{{f.survexdirectory.path}} | -{{f.pathparent}} | -{{f.primary}} | +{{f.cave}} | +{{f.cave.survex_file}} | +{{f.primary}}.svx | {{f.path}}.svx |