renamed tunnel to drawing or dwg

This commit is contained in:
Philip Sargent
2021-04-26 18:08:42 +01:00
parent f0d291f527
commit 37403a7234
5 changed files with 57 additions and 57 deletions

View File

@@ -199,13 +199,13 @@ class SingleScan(models.Model):
def __str__(self):
return "Survey Scan Image: " + str(self.name) + " in " + str(self.scansfolder)
class TunnelFile(models.Model):
class DrawingFile(models.Model):
tunnelpath = models.CharField(max_length=200)
tunnelname = models.CharField(max_length=200)
bfontcolours = models.BooleanField(default=False) # UNUSED now, can be deleted
manyscansfolders = models.ManyToManyField("ScansFolder") # implicitly links via folders to scans to SVX files
scans = models.ManyToManyField("SingleScan") # implicitly links via scans to SVX files
tunnelcontains = models.ManyToManyField("TunnelFile") # case when its a frame type
tunnelcontains = models.ManyToManyField("DrawingFile") # case when its a frame type
filesize = models.IntegerField(default=0)
npaths = models.IntegerField(default=0)
survexfiles = models.ManyToManyField("SurvexFile") # direct link to SVX files - not populated yet

View File

@@ -92,7 +92,7 @@ def controlpanel(request):
import_surveyscans()
import_logbooks()
import_QMs()
import_tunnelfiles()
import_dwgfiles()
import_survexblks()
import_survexpos()
else:

View File

@@ -8,7 +8,7 @@ from django.conf import settings
from django.shortcuts import render
from django.http import HttpResponse, Http404
from troggle.core.models.survex import ScansFolder, SingleScan, SurvexBlock, TunnelFile
from troggle.core.models.survex import ScansFolder, SingleScan, SurvexBlock, DrawingFile
from troggle.core.views.expo import getmimetype
import parsers.surveys
@@ -50,8 +50,8 @@ def scanswallets(request):
def dwgdata(request):
'''Report on all the drawing files in the system. These were loaded by parsing the entire directory tree
'''
tunnelfiles = TunnelFile.objects.all()
return render(request, 'dwgfiles.html', { 'tunnelfiles':tunnelfiles, 'settings': settings })
dwgfiles = DrawingFile.objects.all()
return render(request, 'dwgfiles.html', { 'dwgfiles':dwgfiles, 'settings': settings })
def dwgfilesingle(request, path):
@@ -59,12 +59,12 @@ def dwgfilesingle(request, path):
but it might be a Therion file
'''
try:
tunnelfile = TunnelFile.objects.get(tunnelpath=urlunquote(path))
dwgfile = DrawingFile.objects.get(tunnelpath=urlunquote(path))
except:
message = f'Drawing file error or not found \'{path}\' .'
return render(request, 'errors/generic.html', {'message': message})
tfile = Path(settings.TUNNEL_DATA, tunnelfile.tunnelpath)
tfile = Path(settings.TUNNEL_DATA, dwgfile.tunnelpath)
try: # for display not download
return HttpResponse(content=open(tfile, errors='strict'), content_type="text/xhtml")
except UnicodeDecodeError:
@@ -82,11 +82,11 @@ def dwgfileupload(request, path):
'''uploads a drawing file, but where is the Form? This just processes POST info. Apparently unfinished?
'''
try:
tunnelfile = TunnelFile.objects.get(tunnelpath=urlunquote(path)) # need to check if inavlid query string and produce friendly error
dwgfile = DrawingFile.objects.get(tunnelpath=urlunquote(path)) # need to check if inavlid query string and produce friendly error
except:
message = f'Drawing file error or not found \'{path}\' .'
return render(request, 'errors/generic.html', {'message': message})
tfile = Path(settings.TUNNEL_DATA, tunnelfile.tunnelpath)
tfile = Path(settings.TUNNEL_DATA, dwgfile.tunnelpath)
project, user, password, tunnelversion = request.POST["tunnelproject"], request.POST["tunneluser"], request.POST["tunnelpassword"], request.POST["tunnelversion"]
print(project, user, tunnelversion)
@@ -106,7 +106,7 @@ def dwgfileupload(request, path):
if os.path.split(path)[1] != uploadedfile.name:
return HttpResponse(content="Error: name disagrees", content_type="text/plain")
orgsize = tunnelfile.filesize # = os.stat(tfile)[stat.ST_SIZE]
orgsize = dwgfile.filesize # = os.stat(tfile)[stat.ST_SIZE]
ttext = uploadedfile.read()
@@ -117,11 +117,11 @@ def dwgfileupload(request, path):
fout.close()
# redo its settings of
parsers.surveys.SetTunnelfileInfo(tunnelfile)
tunnelfile.save()
parsers.surveys.SetTunnelfileInfo(dwgfile) # commented out
dwgfile.save()
uploadedfile.close()
message = "File size %d overwritten with size %d" % (orgsize, tunnelfile.filesize)
message = "File size %d overwritten with size %d" % (orgsize, dwgfile.filesize)
return HttpResponse(content=message, content_type="text/plain")