From 27c72a7bc66f68a909b71218b39ddda554fd3810 Mon Sep 17 00:00:00 2001 From: Daniel Quinn Date: Fri, 13 Apr 2018 20:18:16 +0100 Subject: [PATCH] Remove the hard-coding of the thumbnail URL --- src/documents/admin.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/documents/admin.py b/src/documents/admin.py index 232b17684..3d78abab7 100644 --- a/src/documents/admin.py +++ b/src/documents/admin.py @@ -139,19 +139,17 @@ class DocumentAdmin(CommonAdmin): created_.short_description = "Created" def thumbnail(self, obj): - if settings.FORCE_SCRIPT_NAME: - src_link = "{}/fetch/thumb/{}".format( - settings.FORCE_SCRIPT_NAME, obj.id) - else: - src_link = "/fetch/thumb/{}".format(obj.id) - png_img = self._html_tag( - "img", - src=src_link, - width=180, - alt="Thumbnail of {}".format(obj.file_name), - title=obj.file_name + return self._html_tag( + "a", + self._html_tag( + "img", + src=reverse("fetch", kwargs={"kind": "thumb", "pk": obj.pk}), + width=180, + alt="Thumbnail of {}".format(obj.file_name), + title=obj.file_name + ), + href=obj.download_url ) - return self._html_tag("a", png_img, href=obj.download_url) thumbnail.allow_tags = True def tags_(self, obj):