tunnelpath to dwgpath

This commit is contained in:
Philip Sargent 2021-04-26 18:11:14 +01:00
parent 37403a7234
commit dc840c9bc7
5 changed files with 18 additions and 18 deletions

View File

@ -200,7 +200,7 @@ class SingleScan(models.Model):
return "Survey Scan Image: " + str(self.name) + " in " + str(self.scansfolder)
class DrawingFile(models.Model):
tunnelpath = models.CharField(max_length=200)
dwgpath = 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
@ -211,4 +211,4 @@ class DrawingFile(models.Model):
survexfiles = models.ManyToManyField("SurvexFile") # direct link to SVX files - not populated yet
class Meta:
ordering = ('tunnelpath',)
ordering = ('dwgpath',)

View File

@ -59,12 +59,12 @@ def dwgfilesingle(request, path):
but it might be a Therion file
'''
try:
dwgfile = DrawingFile.objects.get(tunnelpath=urlunquote(path))
dwgfile = DrawingFile.objects.get(dwgpath=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, dwgfile.tunnelpath)
tfile = Path(settings.TUNNEL_DATA, dwgfile.dwgpath)
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:
dwgfile = DrawingFile.objects.get(tunnelpath=urlunquote(path)) # need to check if inavlid query string and produce friendly error
dwgfile = DrawingFile.objects.get(dwgpath=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, dwgfile.tunnelpath)
tfile = Path(settings.TUNNEL_DATA, dwgfile.dwgpath)
project, user, password, tunnelversion = request.POST["tunnelproject"], request.POST["tunneluser"], request.POST["tunnelpassword"], request.POST["tunnelversion"]
print(project, user, tunnelversion)

View File

@ -61,7 +61,7 @@ def set_dummy_entrance(id, slug, cave, msg="DUMMY"):
letter = ""
entrances_xslug[slug] = entrance
ce = CaveAndEntrance.objects.update_or_create(cave = cave, entrance_letter = "", entrance = entrance)
message = f' ! Entrance Dummy setting WORKED, slug:"{slug}" cave id:"{id}" '
message = f' ! Warning: Dummy Entrance created for {id}, slug:"{slug}" '
DataIssue.objects.create(parser='caves', message=message, url=f'/cave/{slug}')
print(message)
except:

View File

@ -130,7 +130,7 @@ def find_tunnel_scan(dwgfile, path):
if len(scansfolderl):
scansfolder = scansfolderl[0]
if len(scansfolderl) > 1:
message = "! More than one scan FOLDER matches filter query. [{}]: {} {} {} {}".format(scansfilel[0], mscansdir.group(1), mscansdir.group(2), dwgfile.tunnelpath, path)
message = "! More than one scan FOLDER matches filter query. [{}]: {} {} {} {}".format(scansfilel[0], mscansdir.group(1), mscansdir.group(2), dwgfile.dwgpath, path)
print(message)
DataIssue.objects.create(parser='Tunnel', message=message)
@ -138,7 +138,7 @@ def find_tunnel_scan(dwgfile, path):
scansfilel = scansfolder.singlescan_set.filter(name=mscansdir.group(2))
if len(scansfilel):
if len(scansfilel) > 1:
message = "! More than one image FILENAME matches filter query. [{}]: {} {} {} {}".format(scansfilel[0], mscansdir.group(1), mscansdir.group(2), dwgfile.tunnelpath, path)
message = "! More than one image FILENAME matches filter query. [{}]: {} {} {} {}".format(scansfilel[0], mscansdir.group(1), mscansdir.group(2), dwgfile.dwgpath, path)
print(message)
DataIssue.objects.create(parser='Tunnel', message=message)
scansfile = scansfilel[0]
@ -179,7 +179,7 @@ def settherionfileinfo(filetuple):
'''
thtype, therionfile = filetuple
ff = os.path.join(settings.TUNNEL_DATA, therionfile.tunnelpath)
ff = os.path.join(settings.TUNNEL_DATA, therionfile.dwgpath)
therionfile.filesize = os.stat(ff)[stat.ST_SIZE]
if therionfile.filesize <= 0:
message = "! Zero length therion file {}".format(ff)
@ -206,7 +206,7 @@ def settherionfileinfo(filetuple):
# scrap blownout -projection plan -scale [-81.0 -42.0 216.0 -42.0 0.0 0.0 7.5438 0.0 m]
for xth_me in rx_xth_me.findall(ttext):
message = f'! Un-parsed image filename: {therionfile.tunnelname} : {xth_me.split()[-3]} - {therionfile.tunnelpath}'
message = f'! Un-parsed image filename: {therionfile.tunnelname} : {xth_me.split()[-3]} - {therionfile.dwgpath}'
#print(message)
DataIssue.objects.create(parser='Therion', message=message)
findimageinsert(therionfile, xth_me)
@ -214,7 +214,7 @@ def settherionfileinfo(filetuple):
for inp in rx_input.findall(ttext):
# if this 'input' is a .th2 file we have already seen, then we can assign this as a sub-file
# but we would need to disentangle to get the current path properly
message = f'! Un-set Therion .th2 input: - {therionfile.tunnelname} : {inp} - {therionfile.tunnelpath}'
message = f'! Un-set Therion .th2 input: - {therionfile.tunnelname} : {inp} - {therionfile.dwgpath}'
#print(message)
DataIssue.objects.create(parser='Therion', message=message)
findimportinsert(therionfile, inp)
@ -229,7 +229,7 @@ def setdwgfileinfo(dwgfile):
Should try to read the date too e.g. tunneldate="2010-08-16 22:51:57
then we could display on the master calendar per expo.
'''
ff = os.path.join(settings.TUNNEL_DATA, dwgfile.tunnelpath)
ff = os.path.join(settings.TUNNEL_DATA, dwgfile.dwgpath)
dwgfile.filesize = os.stat(ff)[stat.ST_SIZE]
if dwgfile.filesize <= 0:
message = "! Zero length xml file {}".format(ff)
@ -278,17 +278,17 @@ def load_drawings_files():
drawingsdirs.append(lf) # lunatic! adding to list in middle of list while loop!
elif f[-4:] == ".xml":
# Always creates new
dwgfile = DrawingFile(tunnelpath=lf, tunnelname=os.path.split(f[:-4])[1])
dwgfile = DrawingFile(dwgpath=lf, tunnelname=os.path.split(f[:-4])[1])
dwgfile.save()
all_xml.append(('xml',dwgfile))
elif f[-3:] == ".th":
# Always creates new
dwgfile = DrawingFile(tunnelpath=lf, tunnelname=os.path.split(f[:-4])[1])
dwgfile = DrawingFile(dwgpath=lf, tunnelname=os.path.split(f[:-4])[1])
dwgfile.save()
all_xml.append(('th',dwgfile))
elif f[-4:] == ".th2":
# Always creates new
dwgfile = DrawingFile(tunnelpath=lf, tunnelname=os.path.split(f[:-4])[1])
dwgfile = DrawingFile(dwgpath=lf, tunnelname=os.path.split(f[:-4])[1])
dwgfile.save()
all_xml.append(('th2',dwgfile))

View File

@ -12,7 +12,7 @@
{% for dwgfile in dwgfiles %}
<tr>
<td><a href="{% url "dwgfilesingle" dwgfile.tunnelpath %}">{{dwgfile.tunnelpath}}</a></td>
<td><a href="{% url "dwgfilesingle" dwgfile.dwgpath %}">{{dwgfile.dwgpath}}</a></td>
<td align="right" style="padding:2px">{{dwgfile.filesize}}</td>
<td align="right" style="padding:2px">{{dwgfile.npaths}}</td>
@ -30,7 +30,7 @@
<td style="padding:2px">
{% for rdwgfile in dwgfile.tunnelcontains.all %}
<a href="{% url "dwgfilesingle" rdwgfile.tunnelpath %}">{{rdwgfile.tunnelpath}}</a>
<a href="{% url "dwgfilesingle" rdwgfile.dwgpath %}">{{rdwgfile.dwgpath}}</a>
{% endfor %}
</td>
</tr>