2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

.3d cave file links

This commit is contained in:
Philip Sargent 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=""): 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 """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 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 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: try:
cave = getCave(cave_id) cave = getCave(cave_id)
except ObjectDoesNotExist: except ObjectDoesNotExist:
return HttpResponseNotFound return HttpResponseNotFound
except Cave.MultipleObjectsReturned: except Cave.MultipleObjectsReturned:
# But only one might have survex data? So scan and return the first that works. # should really produce a better error message. This is a failure of ambiguous aliases probably.
caves = getCaves(cave_id) caves = Cave.objects.filter(url=kpath)
for c in caves: return render(request, "svxcaveseveral.html", {"settings": settings, "caves": 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)
else: else:
return file3d(request, cave, cave_id) return file3d(request, cave, cave_id)

View File

@ -202,10 +202,10 @@
{% if cave.survex_file %} {% if cave.survex_file %}
Primary <a href="/survexfile/{{cave.survex_file}}">survex file</a> for this cave Primary <a href="/survexfile/{{cave.survex_file}}">survex file</a> for this cave
<br> <br>
Download .3d file <a href="{% url "cave3d" cave %}">caves-{{ cave.areacode }}/{% if cave.kataster_number %}{{cave.kataster_number}}{% else %}{{cave.unofficial_number}}{% endif %}/{{svx3d}}.3d</a> Download .3d file <a href="{% url "cave3d" cave %}">{% url "cave3d" cave %}</a>
<br> <br>
cave ID '{{cave.reference}}'<br> cave reference '{{cave.reference}}'<br>
cave survex path '{{ cave.areacode }}/{% if cave.kataster_number %}{{cave.kataster_number}}{% else %}{{cave.unofficial_number}}{% endif %}' cave survex path '{{ cave.areacode }}/{% if cave.kataster_number %}{{cave.kataster_number}}{% else %}{{cave.unofficial_number}}{% endif %}/'
<div id='scene'></div> <div id='scene'></div>
{% endif %} {% endif %}
{% endblock content %} {% endblock content %}