diff options
author | Philip Sargent <philip.sargent@klebos.com> | 2022-10-15 18:37:46 +0300 |
---|---|---|
committer | Philip Sargent <philip.sargent@klebos.com> | 2022-10-15 18:37:46 +0300 |
commit | 454c2c2830f0da5b1c482c875fee13ec1e1a66e1 (patch) | |
tree | c26cf8e9ea21fcee8d37ae998d144cbe5ca311b7 /core/views/scans.py | |
parent | 2fa298cae9db9fb5bfc0884c3e2c360c33860a72 (diff) | |
download | troggle-454c2c2830f0da5b1c482c875fee13ec1e1a66e1.tar.gz troggle-454c2c2830f0da5b1c482c875fee13ec1e1a66e1.tar.bz2 troggle-454c2c2830f0da5b1c482c875fee13ec1e1a66e1.zip |
Fix links to scans directly from the master drawings list
Diffstat (limited to 'core/views/scans.py')
-rw-r--r-- | core/views/scans.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/core/views/scans.py b/core/views/scans.py index 79d6ccc..38f1ed8 100644 --- a/core/views/scans.py +++ b/core/views/scans.py @@ -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}) |