Fix the django for the spinny js cave viewer.

Make the paths settings (don't hard code things like this!!)
Add " round spinny urls from the late merge (the rest were done for the move off 1.4.2
This commit is contained in:
Sam Wenham 2018-04-20 20:55:12 +01:00
parent 6f6327d267
commit 46124a770f
2 changed files with 9 additions and 9 deletions

View File

@ -18,7 +18,7 @@ from django.shortcuts import get_object_or_404
import settings import settings
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
import string, os, sys import string, os, sys, subprocess
def getCave(cave_id): def getCave(cave_id):
"""Returns a cave object when given a cave name or number. It is used by views including cavehref, ent, and qm.""" """Returns a cave object when given a cave name or number. It is used by views including cavehref, ent, and qm."""
@ -59,14 +59,14 @@ def caveindex(request):
caves1626.sort(caveCmp) caves1626.sort(caveCmp)
return render_with_context(request,'caveindex.html', {'caves1623': caves1623, 'caves1626': caves1626, 'notablecaves':notablecaves, 'cavepage': True}) return render_with_context(request,'caveindex.html', {'caves1623': caves1623, 'caves1626': caves1626, 'notablecaves':notablecaves, 'cavepage': True})
def cave3d(request, cave_id): def cave3d(request, cave_id=''):
cave = getCave(cave_id) cave = getCave(cave_id)
survexfilename = '/home/expo/loser/' + cave.survex_file survexfilename = settings.SURVEX_DATA + cave.survex_file
threedfilename = '/home/expo/expowebcache/3d/%s.3d' % cave_id threedfilename = settings.THREEDCACHEDIR + '%s.3d' % cave_id
if True or os.path.getmtime(survexfilename) > os.path.getmtime(threedfilename): if True or os.path.getmtime(survexfilename) > os.path.getmtime(threedfilename):
subprocess.call(["cavern", "--output=%s" % threedfilename, survexfilename]) subprocess.call(["cavern", "--output=%s" % threedfilename, survexfilename])
test_file = open(threedfilename, 'rb') test_file = open(threedfilename, 'rb')
response = HttpResponse(content=test_file, mimetype='application/3d')#mimetype is replaced by content_type for django 1.7 response = HttpResponse(content=test_file, content_type='application/3d')#mimetype is replaced by content_type for django 1.7
response['Content-Disposition'] = 'attachment; filename=%s.3d' % cave_id response['Content-Disposition'] = 'attachment; filename=%s.3d' % cave_id
# response['X-Sendfile'] = "%s.3d" % cave_id # response['X-Sendfile'] = "%s.3d" % cave_id
# It's usually a good idea to set the 'Content-Length' header too. # It's usually a good idea to set the 'Content-Length' header too.

View File

@ -564,7 +564,7 @@ div#scene {
{% endif %} {% endif %}
{% if cave.survex_file %} {% if cave.survex_file %}
<h2>Survex File</h2> <h2>Survex File</h2>
{{ cave.survex_file|safe }} <a href="{% if cave.kataster_number %}{% url cave3d cave.kataster_number %}{% else %}{% url cave3d cave.unofficial_number %}{% endif %}">3d file</a> {{ cave.survex_file|safe }} <a href="{% if cave.kataster_number %}{% url "cave3d" cave.kataster_number %}{% else %}{% url "cave3d" cave.unofficial_number %}{% endif %}">3d file</a>
<div id='scene'></div> <div id='scene'></div>
{% endif %} {% endif %}
{% if cave.notes %} {% if cave.notes %}