Better diagnostics from bad slug error

This commit is contained in:
Philip Sargent 2023-02-02 11:19:46 +00:00
parent 3b9695b4f3
commit 578f02db2d
2 changed files with 6 additions and 6 deletions

View File

@ -312,7 +312,7 @@ def caveEntrance(request, slug):
try:
cave = Cave.objects.get(caveslug__slug=slug)
except:
return render(request, "errors/badslug.html", {"badslug": slug})
return render(request, "errors/badslug.html", {"badslug": f"{slug} - from caveEntrance()"})
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated:
return render(request, "nonpublic.html", {"instance": cave})
@ -333,7 +333,7 @@ def edit_cave(request, path="", slug=None):
try:
cave = Cave.objects.get(caveslug__slug=slug)
except:
return render(request, "errors/badslug.html", {"badslug": slug})
return render(request, "errors/badslug.html", {"badslug": f"{slug} - from edit_cave()"})
else:
cave = Cave()
if request.POST:
@ -412,7 +412,7 @@ def edit_entrance(request, path="", caveslug=None, slug=None):
try:
cave = Cave.objects.get(caveslug__slug=caveslug)
except:
return render(request, "errors/badslug.html", {"badslug": caveslug})
return render(request, "errors/badslug.html", {"badslug": f"{slug} {caveslug} - from edit_entrance()"})
if slug:
entrance = Entrance.objects.get(entranceslug__slug=slug)
@ -504,7 +504,7 @@ def get_entrances(request, caveslug):
try:
cave = Cave.objects.get(caveslug__slug=caveslug)
except:
return render(request, "errors/badslug.html", {"badslug": caveslug})
return render(request, "errors/badslug.html", {"badslug": f"{caveslug} - from get_entrances()"})
return render(
request, "options.html", {"items": [(e.entrance.slug(), e.entrance.slug()) for e in cave.entrances()]}
)
@ -518,7 +518,7 @@ def caveQMs(request, slug):
try:
cave = Cave.objects.get(caveslug__slug=slug)
except:
return render(request, "errors/badslug.html", {"badslug": slug})
return render(request, "errors/badslug.html", {"badslug": f"{slug} - from caveQMs()"})
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated:
return render(request, "nonpublic.html", {"instance": cave})

View File

@ -217,7 +217,7 @@ def cavewallets(request, caveid):
if caveid in Gcavelookup:
cave = Gcavelookup[caveid]
else:
return render(request, "errors/badslug.html", {"badslug": caveid})
return render(request, "errors/badslug.html", {"badslug": f"{caveid} - from cavewallets()"})
# remove duplication. Sorting is done in the template
# But this only gets wallets which have survex files attached..