diff --git a/attachments/admin.py b/attachments/admin.py
index 859f088..afa789a 100644
--- a/attachments/admin.py
+++ b/attachments/admin.py
@@ -6,5 +6,20 @@ from attachments.models import Attachment
@register(Attachment)
class AttachmentAdmin(admin.ModelAdmin):
- list_display = ["description", "original_file", "processed_file"]
+ list_display = [
+ "description",
+ "original_file",
+ "original_file_url",
+ "processed_file",
+ "processed_file_url",
+ ]
list_display_links = ["description"]
+
+ class Media:
+ js = ["attachments/js/copy_url.js"]
+
+ def processed_file_url(self, instance):
+ return instance.processed_file.url
+
+ def original_file_url(self, instance):
+ return instance.original_file.url
diff --git a/attachments/static/attachments/js/copy_url.js b/attachments/static/attachments/js/copy_url.js
new file mode 100644
index 0000000..a067f9e
--- /dev/null
+++ b/attachments/static/attachments/js/copy_url.js
@@ -0,0 +1,17 @@
+function copy(data) {
+ navigator.clipboard.writeText(data).then(() => {
+ console.log("Copied");
+ })
+}
+
+$(document).ready(function() {
+ const $ = django.jQuery;
+ const fileUrls = $('td.field-processed_file_url, td.field-original_file_url');
+ for (let fileUrl of fileUrls) {
+ fileUrl = $(fileUrl);
+ const existingText = fileUrl.text();
+ const copyButton = `📋`;
+ let innerHTML = `${existingText} ${copyButton}`;
+ fileUrl.html(innerHTML);
+ }
+});