Remove the hard-coding of the thumbnail URL

This commit is contained in:
Daniel Quinn 2018-04-13 20:18:16 +01:00
parent 72af13e4e4
commit 27c72a7bc6

View File

@ -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):