mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-21 23:01:52 +00:00
infinite loop bug fixed
This commit is contained in:
parent
65f0c1e29f
commit
b73ac24a3b
@ -40,6 +40,10 @@ todo = """
|
||||
- Learn to use Django .select_related() and .prefetch_related() to speed things up
|
||||
especially on the big report pages
|
||||
https://zerotobyte.com/how-to-use-django-select-related-and-prefetch-related/
|
||||
|
||||
- Remove all the URL rewriting which is there because we have not yet edited all the caves to use
|
||||
our new (2023) standard addressing of /16xx/NNN/NNN.html where *all* caves are assumed to have their
|
||||
own directory 16xx/NNN/ even if they have no images to put in it.
|
||||
"""
|
||||
|
||||
|
||||
@ -97,7 +101,7 @@ def numericalcmp(x, y):
|
||||
|
||||
|
||||
def caveKey(c):
|
||||
"""This function goes into a lexicogrpahic sort function, and the values are strings,
|
||||
"""This function goes into a lexicographic sort function, and the values are strings,
|
||||
but we want to sort numberically on kataster number before sorting on unofficial number.
|
||||
"""
|
||||
if not c.kataster_number:
|
||||
@ -337,11 +341,14 @@ def cavepage(request, karea=None, subpath=None):
|
||||
|
||||
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.
|
||||
But this confused Becka so it was re-instated. Thus creating more confusion for future generations...
|
||||
|
||||
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 not subpath or subpath=='/':
|
||||
print(f"{karea=} {subpath=} ")
|
||||
return render(request, "pagenotfound.html", {"path": f"{karea}/{subpath}"}, status=404)
|
||||
# lack of validation for karea, 162x
|
||||
# subpath has an initial /
|
||||
kpath = karea + subpath
|
||||
@ -353,6 +360,7 @@ def cavepage(request, karea=None, subpath=None):
|
||||
return rendercave(request, cave, cave.slug())
|
||||
|
||||
|
||||
subpath = subpath.strip("//")
|
||||
# re do all this using pathlib functions
|
||||
parts = subpath.strip("/").split("/")
|
||||
if len(parts) > 5:
|
||||
@ -367,11 +375,10 @@ def cavepage(request, karea=None, subpath=None):
|
||||
else:
|
||||
return redirect(f"/caves")
|
||||
|
||||
# BUGGER the real problem is the the cave descrit has embedded in it images like
|
||||
# BUGGER the real problem is the the cave descript has embedded in it images like
|
||||
# src="110/entrance.jpeg and since the cave url is now /1623/110/110.html
|
||||
# the images try to load from /1623/110/110/entrance.jpeg and of course fail.
|
||||
# THIS IS A HORRIBLE HACK
|
||||
|
||||
if len(parts) == 1: # simple filename, no folders in path, need to insert caveid
|
||||
subparts = parts[0].split(".")
|
||||
caveid = subparts[0]
|
||||
|
Loading…
Reference in New Issue
Block a user