From 322a9abf9edd14fc7418b460ad5c3ed6d9eec79d Mon Sep 17 00:00:00 2001
From: mlbonhomme <bonhomme@teklia.com>
Date: Tue, 27 Sep 2022 07:38:56 +0000
Subject: [PATCH] Link to image in Element admin

---
 arkindex/documents/admin.py | 6 +++---
 arkindex/images/models.py   | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arkindex/documents/admin.py b/arkindex/documents/admin.py
index 9d41d26f50..6884239cf7 100644
--- a/arkindex/documents/admin.py
+++ b/arkindex/documents/admin.py
@@ -86,9 +86,9 @@ class MetaDataInline(admin.TabularInline):
 class ElementAdmin(admin.ModelAdmin):
     list_display = ('id', 'name', 'type', 'corpus', )
     list_filter = ['type__slug', 'corpus']
-    fields = ('id', 'type', 'name', 'corpus', 'confidence', 'worker_run', )
-    raw_id_fields = ('worker_run', )
-    readonly_fields = ('id', 'corpus', )
+    fields = ('id', 'type', 'name', 'image', 'corpus', 'confidence', 'worker_run', )
+    raw_id_fields = ('worker_run',)
+    readonly_fields = ('id', 'corpus', 'image',)
     search_fields = ('name', )
     inlines = (MetaDataInline, ClassificationInline)
 
diff --git a/arkindex/images/models.py b/arkindex/images/models.py
index 40a90d6c9e..a3b7ca6a9c 100644
--- a/arkindex/images/models.py
+++ b/arkindex/images/models.py
@@ -329,7 +329,8 @@ class Image(S3FileMixin, IndexableModel):
             self.width, self.height = new_width, new_height
 
     def __str__(self):
-        return '{} - {}'.format(self.id, self.url)
+        # Used by admin
+        return self.url
 
 
 class Thumbnail(S3FileMixin):
-- 
GitLab