diff --git a/core/views_caves.py b/core/views_caves.py index 2dcef5e..db3e52d 100644 --- a/core/views_caves.py +++ b/core/views_caves.py @@ -17,7 +17,7 @@ import re, urlparse from django.shortcuts import get_object_or_404 import settings -import Image, ImageDraw, ImageFont, string, os, sys +import Image, ImageDraw, ImageFont, 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.""" @@ -58,12 +58,26 @@ 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): + cave = getCave(cave_id) + survexfilename = '/home/expo/loser/' + cave.survex_file + threedfilename = '/home/expo/expowebcache/3d/%s.3d' % cave_id + if True or os.path.getmtime(survexfilename) > os.path.getmtime(threedfilename): + 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['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. + # You can also set any other required headers: Cache-Control, etc. + return response + def cave(request, cave_id='', offical_name=''): cave=getCave(cave_id) if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated(): - return render_with_context(request,'nonpublic.html', {'instance': cave, 'cavepage': True}) + return render_with_context(request,'nonpublic.html', {'instance': cave, 'cavepage': True, 'cave_id': cave_id}) else: - return render_with_context(request,'cave.html', {'settings': settings, 'cave': cave, 'cavepage': True}) + return render_with_context(request,'cave.html', {'settings': settings, 'cave': cave, 'cavepage': True, 'cave_id': cave_id}) def caveEntrance(request, slug): cave = Cave.objects.get(caveslug__slug = slug) @@ -202,7 +216,7 @@ def qm(request,cave_id,qm_id,year,grade=None): return HttpResponseRedirect(url) - + def ent(request, cave_id, ent_letter): cave = Cave.objects.filter(kataster_number = cave_id)[0] cave_and_ent = CaveAndEntrance.objects.filter(cave = cave).filter(entrance_letter = ent_letter)[0] diff --git a/templates/cave.html b/templates/cave.html index 5bd77f6..a8321a8 100644 --- a/templates/cave.html +++ b/templates/cave.html @@ -1,5 +1,438 @@ {% extends "cavebase.html" %} +{% block extraheaders %} +{% if cave.survex_file %} + + + + + + + +{% endif %} +{% endblock %} + + {% load wiki_markup %} {% block content %} {% block contentheader %} @@ -131,7 +564,8 @@ {% endif %} {% if cave.survex_file %}