2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 08:41:51 +00:00

Survex directories report tidied

This commit is contained in:
Philip Sargent 2023-09-07 00:01:03 +03:00
parent 69340db438
commit 2c5ebde308
3 changed files with 17 additions and 20 deletions

View File

@ -297,14 +297,14 @@ def rendercave(request, cave, slug, cave_id=""):
return r return r
def cavepage(request, karea, subpath): def cavepage(request, karea=None, subpath=None, slug=None):
"""Displays a cave description page """Displays a cave description page
accessed by kataster area number specifically accessed by kataster area number specifically
OR OR
accessed by cave.url specifically set in data, e.g. accessed by cave.url specifically set in data, e.g.
"1623/000/000" <= cave-data/1623-000.html "1623/000/000" <= cave-data/1623-000.html
"1623/41/115.htm" <= cave-data/1623-115.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 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. 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 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). 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 kpath = karea + subpath
# print(f" ! cavepage:'{kpath}' kataster area:'{karea}' rest of path:'{subpath}'") # print(f" ! cavepage:'{kpath}' kataster area:'{karea}' rest of path:'{subpath}'")
try: try:
cave = Cave.objects.get(url=kpath) # ideally this will be unique cave = Cave.objects.get(url=kpath) # ideally this will be unique
except Cave.DoesNotExist: except Cave.DoesNotExist:

View File

@ -4,29 +4,17 @@
{% block content %} {% block content %}
{% autoescape off %} {% autoescape off %}
<h1>SurvexDirectory objects</h1> <h1>Survex Primary files: per Cave and per directory</h1>
{% endautoescape %} {% endautoescape %}
<h2>All SurvexDirectories</h2>
<table>
<tr><th>Dir Path</th><th>Primary svx</th></tr>
{% for sd in survexdirs %}
<tr>
<td><span{% if sd.matchbad %} style="color:red" {% endif %}>{{sd.path}}</span></td>
<td><a href="/survexfile/{{sd.primarysurvexfile}}.svx"><span {% if sd.pathbad %} style="color:red" {% endif %}>{{sd.primarysurvexfile}}.svx</span></a></td>
</tr>
{% endfor %}
</table>
<p>
<h2>All SurvexFiles</h2> <h2>All SurvexFiles</h2>
<table> <table>
<tr><th>Cave</th><th>f.survexdirectory.path</th><th>f.primary.path.parent()</th><th>f.primary</th><th>f.path</th></tr> <tr><th>Cave</th><th>Cave primary</th><th>f.primary</th><th>f.path</th></tr>
{% for f in survexfiles %} {% for f in survexfiles %}
<tr> <tr>
<td>{{f.cave}}</td> <td><a href="/cave/{{f.cave}}">{{f.cave}}</a></td>
<td><span {% if f.matchbad %} style="color:red" {% endif %}>{{f.survexdirectory.path}}</span></td> <td>{{f.cave.survex_file}}</td>
<td><span {% if f.primarybad %} style="color:red" {% endif %}>{{f.pathparent}}</span></td> <td> {{f.primary}}.svx</td>
<td> {{f.primary}}</td>
<td><span {% if f.pathbad %} style="color:red" {% endif %}><a href="/survexfile/{{f.path}}.svx">{{f.path}}.svx</a></span></td> <td><span {% if f.pathbad %} style="color:red" {% endif %}><a href="/survexfile/{{f.path}}.svx">{{f.path}}.svx</a></span></td>
</tr> </tr>
{% endfor %} {% endfor %}

View File

@ -141,6 +141,7 @@ trogglepatterns = [
re_path(r'^getEntrances/(?P<caveslug>.*)', get_entrances, name = "get_entrances"), # used internally ? re_path(r'^getEntrances/(?P<caveslug>.*)', get_entrances, name = "get_entrances"), # used internally ?
# Cave description pages # Cave description pages
path('cave/<slug:slug>', cavepage, name="cavepage"),
path('cave_debug', cave_debug, name="cave_debug"), path('cave_debug', cave_debug, name="cave_debug"),
re_path(r'^newcave/$', edit_cave, name="newcave"), re_path(r'^newcave/$', edit_cave, name="newcave"),
re_path(r'^cave/3d/(?P<cave_id>[^/]+).3d$', cave3d, name="cave3d"), re_path(r'^cave/3d/(?P<cave_id>[^/]+).3d$', cave3d, name="cave3d"),