mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-22 07:11:52 +00:00
fixed duplicate paths to same page
This commit is contained in:
parent
8dcae6437e
commit
c884156889
@ -10,7 +10,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
|
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
|
||||||
from django.http import HttpResponse, HttpResponseNotFound, HttpResponseRedirect, FileResponse
|
from django.http import HttpResponse, HttpResponseNotFound, HttpResponseRedirect, FileResponse
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render, redirect
|
||||||
from django.urls import NoReverseMatch, reverse
|
from django.urls import NoReverseMatch, reverse
|
||||||
|
|
||||||
import troggle.settings as settings
|
import troggle.settings as settings
|
||||||
@ -289,9 +289,27 @@ def rendercave(request, cave, slug, cave_id=""):
|
|||||||
request, templatefile, context
|
request, templatefile, context
|
||||||
) # crashes here with NoReverseMatch if url not set up for 'edit_cave' in urls.py
|
) # crashes here with NoReverseMatch if url not set up for 'edit_cave' in urls.py
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
def cavepagefwd(request, karea=None, subpath=None):
|
||||||
|
"""archaic, just send to the caves list page
|
||||||
|
"""
|
||||||
|
return redirect("/caves")
|
||||||
|
|
||||||
|
def caveslugfwd(request, slug):
|
||||||
def cavepage(request, karea=None, subpath=None, slug=None):
|
"""This is ass backwards. It would be better style to have the slug-identified request be the master, and have
|
||||||
|
other paths redirect to it, rather than what we have here.
|
||||||
|
Pending a change where we remove cave.url as a field and have an explicit fixed convention instead.
|
||||||
|
"""
|
||||||
|
if slug:
|
||||||
|
Gcavelookup = GetCaveLookup()
|
||||||
|
if slug in Gcavelookup:
|
||||||
|
cave = Gcavelookup[slug]
|
||||||
|
else:
|
||||||
|
message = f"Failed to find cave from identifier given: {slug}."
|
||||||
|
return render(request, "errors/generic.html", {"message": message})
|
||||||
|
return redirect(f"/{cave.url}")
|
||||||
|
|
||||||
|
def cavepage(request, karea=None, subpath=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
|
||||||
@ -306,16 +324,9 @@ def cavepage(request, karea=None, subpath=None, slug=None):
|
|||||||
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})
|
|
||||||
|
|
||||||
# lack of validation for karea, it could be any 4 digits.
|
# lack of validation for karea, it could be any 4 digits.
|
||||||
|
# subpath has an initial /
|
||||||
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:
|
||||||
|
8
urls.py
8
urls.py
@ -7,7 +7,7 @@ from django.conf.urls.static import static
|
|||||||
from troggle.core.views import statistics, survex
|
from troggle.core.views import statistics, survex
|
||||||
from troggle.core.views.auth import expologin, expologout
|
from troggle.core.views.auth import expologin, expologout
|
||||||
from troggle.core.views.caves import (cave3d, caveindex, entranceindex,
|
from troggle.core.views.caves import (cave3d, caveindex, entranceindex,
|
||||||
cavepage, caveQMs, edit_cave, cave_debug,
|
cavepage, caveslugfwd, cavepagefwd, caveQMs, edit_cave, cave_debug,
|
||||||
edit_entrance, get_entrances, qm, expo_kml, expo_kmz)
|
edit_entrance, get_entrances, qm, expo_kml, expo_kmz)
|
||||||
from troggle.core.views.drawings import dwgallfiles, dwgfilesingle
|
from troggle.core.views.drawings import dwgallfiles, dwgfilesingle
|
||||||
from troggle.core.views.editor_helpers import image_selector, new_image_form
|
from troggle.core.views.editor_helpers import image_selector, new_image_form
|
||||||
@ -142,7 +142,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/<slug:slug>', caveslugfwd, name="caveslugfwd"),
|
||||||
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"),
|
||||||
@ -162,8 +162,8 @@ trogglepatterns = [
|
|||||||
# Note that _edit$ for a cave description page in a subfolder e.g. /1623/204/204.html_edit gets caught here and breaks with 404
|
# Note that _edit$ for a cave description page in a subfolder e.g. /1623/204/204.html_edit gets caught here and breaks with 404
|
||||||
|
|
||||||
# These re-enable archaic URLs which are in old web pages which are still public on other servers
|
# These re-enable archaic URLs which are in old web pages which are still public on other servers
|
||||||
path('smkridge/<path:subpath>', cavepage, {'karea': "1623/"}, name="cavepage"),
|
path('smkridge/<path:subpath>', cavepagefwd, {'karea': "1623"}, name="cavepagefwd"),
|
||||||
path('expo/smkridge/<path:subpath>', cavepage, {'karea': "1623/"}, name="cavepage"),
|
path('expo/smkridge/<path:subpath>', cavepagefwd, {'karea': "1623"}, name="cavepagefwd"),
|
||||||
|
|
||||||
# Archaic, kept. This /expo/ prefix only works for expoweb HTML pages not troggle pages
|
# Archaic, kept. This /expo/ prefix only works for expoweb HTML pages not troggle pages
|
||||||
path('expo/<path:path>', expopage, name="expopage"),
|
path('expo/<path:path>', expopage, name="expopage"),
|
||||||
|
Loading…
Reference in New Issue
Block a user