2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

Fix links to scans directly from the master drawings list

This commit is contained in:
Philip Sargent 2022-10-15 18:37:46 +03:00
parent 2fa298cae9
commit 454c2c2830
2 changed files with 13 additions and 5 deletions

View File

@ -30,7 +30,7 @@ def unescape(input):
""" : "\"",
"&tab;" : "\t",
"&backslash;" : "\\",
"&newline;" : "\n\t",
"&newline;" : "\n|\t",
"&apostrophe": "'",
}
for c in codes:

View File

@ -243,12 +243,20 @@ def scansingle(request, path, file):
'''sends a single binary file to the user for display - browser decides how using mimetype
'''
try:
wallet = Wallet.objects.get(walletname=urlunquote(path))
wallet = Wallet.objects.get(walletname=urlunquote(path))
singlescan = SingleScan.objects.get(wallet=wallet, name=file)
print(" - scansingle {}:{}:{}:".format(path, file, getmimetype(file)))
return HttpResponse(content=open(singlescan.ffile,"rb"), content_type=getmimetype(file)) # any type of image
imagefile = Path(singlescan.ffile, file)
if imagefile.is_file():
message = f" - scansingle {imagefile} {path}:{file}:{getmimetype(file)}:"
print(message)
return HttpResponse(content=open(imagefile,"rb"), content_type=getmimetype(file)) # any type of image
else:
message = f'Scan folder file \'{imagefile}\' not found. {path=} {file=}'
print(message)
return render(request, 'errors/generic.html', {'message': message})
except:
message = f'Scan folder or scan item error or not found \'{path}\' and \'{file}\'.'
message = f'Scan folder or scan item access error \'{path}\' and \'{file}\'.'
return render(request, 'errors/generic.html', {'message': message})