Fix for missing processed file

This commit is contained in:
Gabriel Augendre 2020-08-28 21:58:18 +02:00
parent 1eb72f45ef
commit 9813b4252b
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4
2 changed files with 10 additions and 3 deletions

View file

@ -19,7 +19,11 @@ class AttachmentAdmin(admin.ModelAdmin):
js = ["attachments/js/copy_url.js"]
def processed_file_url(self, instance):
if instance.processed_file:
return instance.processed_file.url
return ""
def original_file_url(self, instance):
if instance.original_file:
return instance.original_file.url
return ""

View file

@ -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 = `<a class='copy-button' href='#' onclick="copy(\'${existingText}\')">&#128203;</a>`;
let innerHTML = `<span>${existingText}</span> ${copyButton}`;
fileUrl.html(innerHTML);