mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-04-21 14:09:35 +01:00
fixed duplicate paths to same page
This commit is contained in:
@@ -10,7 +10,7 @@ from pathlib import Path
|
||||
|
||||
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
|
||||
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
|
||||
|
||||
import troggle.settings as settings
|
||||
@@ -289,9 +289,27 @@ def rendercave(request, cave, slug, cave_id=""):
|
||||
request, templatefile, context
|
||||
) # crashes here with NoReverseMatch if url not set up for 'edit_cave' in urls.py
|
||||
return r
|
||||
|
||||
def cavepagefwd(request, karea=None, subpath=None):
|
||||
"""archaic, just send to the caves list page
|
||||
"""
|
||||
return redirect("/caves")
|
||||
|
||||
|
||||
def cavepage(request, karea=None, subpath=None, slug=None):
|
||||
def caveslugfwd(request, slug):
|
||||
"""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
|
||||
accessed by kataster area number specifically
|
||||
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
|
||||
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.
|
||||
# subpath has an initial /
|
||||
kpath = karea + subpath
|
||||
# print(f" ! cavepage:'{kpath}' kataster area:'{karea}' rest of path:'{subpath}'")
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user