2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-14 22:27:20 +00:00

Drawings uploads git works

This commit is contained in:
Philip Sargent
2022-03-05 22:16:03 +00:00
parent a3a65524b8
commit 7a58aac08e
4 changed files with 54 additions and 21 deletions

View File

@@ -179,7 +179,7 @@ def settnlfileinfo(dwgfile):
def setdrwfileinfo(dwgfile):
'''Read in the drawing file contents and sets values on the dwgfile object,
but these are PDFs or .txt files, so there is no useful format to search for
but these are SVGs, PDFs or .txt files, so there is no useful format to search for
This function is a placeholder in case we thnk of a way to do something
to recognise generic survex filenames.
'''
@@ -190,7 +190,6 @@ def setdrwfileinfo(dwgfile):
print(message)
DataIssue.objects.create(parser='drawings', message=message, url=f'/dwgdataraw/{dwgfile.dwgpath}')
return
def load_drawings_files():
'''Breadth first search of drawings directory looking for sub-directories and *.xml filesize
@@ -198,7 +197,8 @@ def load_drawings_files():
Why do we have all this detection of file types/! Why not use get_mime_types ?
What is it all for ??
ALL THIS NEEDS TO DETECT UPPER CASE suffices
We import JPG, PNG and SVG files; which have already been put on the server,
but the upload form intentionally refuses to upload PNG and JPG (though it does allow SVG)
'''
all_xml = []
drawdatadir = settings.DRAWINGS_DATA
@@ -243,6 +243,11 @@ def load_drawings_files():
dwgfile = DrawingFile(dwgpath=lf, dwgname=os.path.split(f[:-4])[1])
dwgfile.save()
all_xml.append(('pdf',dwgfile))
elif Path(f).suffix.lower() == ".png":
# Always creates new
dwgfile = DrawingFile(dwgpath=lf, dwgname=os.path.split(f[:-4])[1])
dwgfile.save()
all_xml.append(('png',dwgfile))
elif Path(f).suffix.lower() == ".svg":
# Always creates new
dwgfile = DrawingFile(dwgpath=lf, dwgname=os.path.split(f[:-4])[1])
@@ -262,7 +267,7 @@ def load_drawings_files():
print(f' - {len(all_xml)} Drawings files found')
for d in all_xml:
if d[0] in ['pdf', 'txt', '']:
if d[0] in ['pdf', 'txt', 'svg', 'jpg', 'png', '']:
setdrwfileinfo(d[1])
if d[0] == 'xml':
settnlfileinfo(d[1])