2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-17 16:17:12 +00:00

.3d cave file links

This commit is contained in:
2023-09-15 22:41:02 +03:00
parent 29879fdde2
commit 3390f17aa4
2 changed files with 6 additions and 13 deletions

View File

@@ -146,26 +146,19 @@ def entranceindex(request):
)
def cave3d(request, cave_id=""):
"""This is used to create a download url in templates/cave.html if anyone wants to download the .3d file
The caller template tries kataster first, then unofficial_number if that kataster number does not exist
but only if Cave.survex_file is non-empty
But the template file cave.html has its own ideas about the name of the file and thus the href. Ouch.
/cave/3d/<cave_id>
"""
try:
cave = getCave(cave_id)
except ObjectDoesNotExist:
return HttpResponseNotFound
except Cave.MultipleObjectsReturned:
# But only one might have survex data? So scan and return the first that works.
caves = getCaves(cave_id)
for c in caves:
if c.survex_file:
# exists, but may not be a valid file path to a valid .svx file in the Loser repo
return file3d(request, c, c.slug)
# should really produce a better error message. This is a failure of ambiguous aliases probably.
caves = Cave.objects.filter(url=kpath)
return render(request, "svxcaveseveral.html", {"settings": settings, "caves": caves})
else:
return file3d(request, cave, cave_id)