From 9813b4252b9d104c885e909d20903b78cc5d26fa Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Fri, 28 Aug 2020 21:58:18 +0200 Subject: [PATCH] Fix for missing processed file --- attachments/admin.py | 8 ++++++-- attachments/static/attachments/js/copy_url.js | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/attachments/admin.py b/attachments/admin.py index afa789a..2d69f13 100644 --- a/attachments/admin.py +++ b/attachments/admin.py @@ -19,7 +19,11 @@ class AttachmentAdmin(admin.ModelAdmin): js = ["attachments/js/copy_url.js"] def processed_file_url(self, instance): - return instance.processed_file.url + if instance.processed_file: + return instance.processed_file.url + return "" def original_file_url(self, instance): - return instance.original_file.url + if instance.original_file: + return instance.original_file.url + return "" diff --git a/attachments/static/attachments/js/copy_url.js b/attachments/static/attachments/js/copy_url.js index a067f9e..0ac4097 100644 --- a/attachments/static/attachments/js/copy_url.js +++ b/attachments/static/attachments/js/copy_url.js @@ -9,7 +9,10 @@ $(document).ready(function() { const fileUrls = $('td.field-processed_file_url, td.field-original_file_url'); for (let fileUrl of fileUrls) { fileUrl = $(fileUrl); - const existingText = fileUrl.text(); + const existingText = fileUrl.text().trim(); + if (!existingText) { + continue; + } const copyButton = `📋`; let innerHTML = `${existingText} ${copyButton}`; fileUrl.html(innerHTML);