From af13e84c74790032d9280fc0487b1e0f0383ef5b Mon Sep 17 00:00:00 2001 From: Sam Wenham Date: Fri, 20 Apr 2018 20:55:12 +0100 Subject: [PATCH] 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 --- core/views_caves.py | 16 ++++++++-------- templates/cave.html | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/views_caves.py b/core/views_caves.py index f6a2bcf..ecf26d5 100644 --- a/core/views_caves.py +++ b/core/views_caves.py @@ -18,7 +18,7 @@ from django.shortcuts import get_object_or_404 import settings from PIL import Image, ImageDraw, ImageFont -import string, os, sys +import string, os, sys, subprocess 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.""" @@ -59,14 +59,14 @@ def caveindex(request): caves1626.sort(caveCmp) 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) - survexfilename = '/home/expo/loser/' + cave.survex_file - threedfilename = '/home/expo/expowebcache/3d/%s.3d' % cave_id + survexfilename = settings.SURVEX_DATA + cave.survex_file + threedfilename = settings.THREEDCACHEDIR + '%s.3d' % cave_id 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') - 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['X-Sendfile'] = "%s.3d" % cave_id # It's usually a good idea to set the 'Content-Length' header too. @@ -334,8 +334,8 @@ for n in maps.keys(): W = (R-L)/2 H = (T-B)/2 for i in range(2): - for j in range(2): - maps["%s%i%i" % (n, i, j)] = [L + i * W, T - j * H, L + (i + 1) * W, T - (j + 1) * H, S, name] + for j in range(2): + maps["%s%i%i" % (n, i, j)] = [L + i * W, T - j * H, L + (i + 1) * W, T - (j + 1) * H, S, name] # Keys in the order in which we want the maps output mapcodes = ["all", "grieß","40", "76", "204", "tc"] # Field codes diff --git a/templates/cave.html b/templates/cave.html index 6589a48..1ba898e 100644 --- a/templates/cave.html +++ b/templates/cave.html @@ -564,7 +564,7 @@ div#scene { {% endif %} {% if cave.survex_file %}

Survex File

- {{ cave.survex_file|safe }} 3d file + {{ cave.survex_file|safe }} 3d file
{% endif %} {% if cave.notes %}