2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2026-01-18 16:42:48 +00:00

tidied survex file editing error conditions

This commit is contained in:
2025-12-18 23:36:22 +00:00
parent 484698e565
commit 9870c00c91
2 changed files with 21 additions and 16 deletions

View File

@@ -658,42 +658,47 @@ def get_primaries(cave):
sds.append(sp)
return list(set(sds))
def survexcavesingle(request, cave_shortname):
def survex_by_cave_id(request, svx_filepath):
"""parsing all the survex files of a single cave and showing that it's consistent and can find all
the files and people.
But might also be a link to a single survex file with no ".svx" suffix, which may not be a cave.
'svx_filepath' might be 'caves-1623/264/264" or it might be "surface/1623/78to78d
If it ends in .svx it will be sent straight to svx()
If cave_shortname=="" then it used to list all caves which did not have a kataser number,
But might also be a link to a single survex file with no ".svx" suffix.
If svx_filepath=="" then it used to list all caves which did not have a kataser number,
an accident of coding. This now does not happen because urls.py has been changed to stop it.
"""
if cave_shortname.startswith("caves-16"):
return svx(request, cave_shortname)
# These are the editable folders below 'loser'
prefixes = ("fixedpts", "gpx", "kataster", "subsections", "surface", "template", "caves-16")
if svx_filepath.startswith(prefixes): # then it is a survex file, not a cave id
return svx(request, svx_filepath)
Gcavelookup = GetCaveLookup()
if cave_shortname in Gcavelookup:
cave = Gcavelookup[cave_shortname]
# print(f"survexcavesingle {cave_shortname=} => {cave=}")
if svx_filepath in Gcavelookup:
cave = Gcavelookup[svx_filepath]
# print(f"survex_by_cave_id {svx_filepath=} => {cave=}")
cave.sds = get_primaries(cave)
return render(request, "svxcaves.html", {"settings": settings, "caves": [cave], "year": current_expo()})
else:
caves = Cave.objects.filter(kataster_number=cave_shortname)
caves = Cave.objects.filter(kataster_number=svx_filepath)
if len(caves) > 0:
# print(f"many {cave_shortname=} => {caves=}")
# print(f"many {svx_filepath=} => {caves=}")
for cave in caves:
cave.sds = get_primaries(cave)
# print(f"many {cave=} => {cave.sds=}")
return render(request, "svxcaves.html", {"settings": settings, "caves": caves, "year": current_expo()})
else:
# A decision needs to be made: is this a silly thing or is it a real file?
filepath = settings.SURVEX_DATA / cave_shortname
filepath = settings.SURVEX_DATA / svx_filepath
print(f" - {filepath=}\n - {svx_filepath=}")
if filepath.is_file():
print(filepath, type(filepath))
# survex file not a cave, e.g. surface/1623/allsurface.svx
return svx(request, cave_shortname)
return svx(request, svx_filepath)
else:
return render(request, "errors/svxcaves404.html", {"settings": settings, "cave": cave_shortname, "year": current_expo()})
return render(request, "errors/svxcaves404.html", {"settings": settings, "cave": svx_filepath, "year": current_expo()})
def check_cave_registered(areacode, survex_cave):
"""Checks whether a cave has been properly registered when it is found in the Loser repo

View File

@@ -296,14 +296,14 @@ trogglepatterns = [
# The survexfile pages
path('survexdir', survex.survexdir, name="survexdir"),
# path('survexfile', survex.survexcavesingle, {'cave_shortname': ''}, name="survexcavessingle"),
# path('survexfile', survex.survex_by_cave_id, {'svx_filepath': ''}, name="survex_by_cave_id"),
path('survexfile/caves', survex.survexcaveslist, name="survexcaveslist"),
path('survexfile/<path:survex_file>.svx', survex.svx, name="svx"),
path('survexfile/<path:survex_file>.3d', survex.threed, name="threed"),
path('survexfile/<path:survex_file>.log', survex.svxlog, name="svxlog"),
path('survexfile/<path:survex_file>.err', survex.err, name="err"),
path('survexfile/<path:cave_shortname>', survex.survexcavesingle, name="survexcavessingle"),
path('survexfile/<path:svx_filepath>', survex.survex_by_cave_id, name="survex_by_cave_id"),
path('survexfilewild', statistics.svxfilewild, name="svxfilewild"),
path('survexfilewild/<int:year>', statistics.svxfilewild, name="svxfilewild"),