diff --git a/core/view_surveys.py b/core/view_surveys.py index 0e958c7..aad48c3 100644 --- a/core/view_surveys.py +++ b/core/view_surveys.py @@ -6,6 +6,7 @@ import os, stat import re from troggle.core.models import SurvexScansFolder, SurvexScanSingle, SurvexBlock, TunnelFile import parsers.surveys +import urllib # inline fileabstraction into here if it's not going to be useful anywhere else # keep things simple and ignore exceptions everywhere for now @@ -17,7 +18,7 @@ def getMimeType(extension): "html": "text/html", }[extension] except: - print "unknown file type" + print("unknown file type") return "text/plain" @@ -166,11 +167,11 @@ def jgtuploadfile(request): def surveyscansfolder(request, path): #print [ s.walletname for s in SurvexScansFolder.objects.all() ] - survexscansfolder = SurvexScansFolder.objects.get(walletname=path) + survexscansfolder = SurvexScansFolder.objects.get(walletname=urllib.unquote(path)) return render_to_response('survexscansfolder.html', { 'survexscansfolder':survexscansfolder, 'settings': settings }) def surveyscansingle(request, path, file): - survexscansfolder = SurvexScansFolder.objects.get(walletname=path) + survexscansfolder = SurvexScansFolder.objects.get(walletname=urllib.unquote(path)) survexscansingle = SurvexScanSingle.objects.get(survexscansfolder=survexscansfolder, name=file) return HttpResponse(content=open(survexscansingle.ffile), content_type=getMimeType(path.split(".")[-1])) #return render_to_response('survexscansfolder.html', { 'survexscansfolder':survexscansfolder, 'settings': settings }) @@ -186,12 +187,12 @@ def tunneldata(request): def tunnelfile(request, path): - tunnelfile = TunnelFile.objects.get(tunnelpath=path) + tunnelfile = TunnelFile.objects.get(tunnelpath=urllib.unquote(path)) tfile = os.path.join(settings.TUNNEL_DATA, tunnelfile.tunnelpath) return HttpResponse(content=open(tfile), content_type="text/plain") def tunnelfileupload(request, path): - tunnelfile = TunnelFile.objects.get(tunnelpath=path) + tunnelfile = TunnelFile.objects.get(tunnelpath=urllib.unquote(path)) tfile = os.path.join(settings.TUNNEL_DATA, tunnelfile.tunnelpath) project, user, password, tunnelversion = request.POST["tunnelproject"], request.POST["tunneluser"], request.POST["tunnelpassword"], request.POST["tunnelversion"]