Fix for missing processed file
This commit is contained in:
parent
1eb72f45ef
commit
9813b4252b
2 changed files with 10 additions and 3 deletions
|
@ -19,7 +19,11 @@ class AttachmentAdmin(admin.ModelAdmin):
|
||||||
js = ["attachments/js/copy_url.js"]
|
js = ["attachments/js/copy_url.js"]
|
||||||
|
|
||||||
def processed_file_url(self, instance):
|
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):
|
def original_file_url(self, instance):
|
||||||
return instance.original_file.url
|
if instance.original_file:
|
||||||
|
return instance.original_file.url
|
||||||
|
return ""
|
||||||
|
|
|
@ -9,7 +9,10 @@ $(document).ready(function() {
|
||||||
const fileUrls = $('td.field-processed_file_url, td.field-original_file_url');
|
const fileUrls = $('td.field-processed_file_url, td.field-original_file_url');
|
||||||
for (let fileUrl of fileUrls) {
|
for (let fileUrl of fileUrls) {
|
||||||
fileUrl = $(fileUrl);
|
fileUrl = $(fileUrl);
|
||||||
const existingText = fileUrl.text();
|
const existingText = fileUrl.text().trim();
|
||||||
|
if (!existingText) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const copyButton = `<a class='copy-button' href='#' onclick="copy(\'${existingText}\')">📋</a>`;
|
const copyButton = `<a class='copy-button' href='#' onclick="copy(\'${existingText}\')">📋</a>`;
|
||||||
let innerHTML = `<span>${existingText}</span> ${copyButton}`;
|
let innerHTML = `<span>${existingText}</span> ${copyButton}`;
|
||||||
fileUrl.html(innerHTML);
|
fileUrl.html(innerHTML);
|
||||||
|
|
Reference in a new issue