summaryrefslogtreecommitdiff
path: root/app/blog/widgets.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2014-05-23 11:28:10 -0400
committerluxagraf <sng@luxagraf.net>2014-05-23 11:28:10 -0400
commit518b2d618bc10f93cfa44a83715593b8358eb9ce (patch)
treea07993c3ae31bed42f32c0e00788989568790716 /app/blog/widgets.py
parent4bae11bb25a8e3c43118891d17fd8e981ecf8dc6 (diff)
minor refactor to adoipt pep8 and pyflakes coding styles and clean up
some cruft that's been hangin round for years
Diffstat (limited to 'app/blog/widgets.py')
-rw-r--r--app/blog/widgets.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/app/blog/widgets.py b/app/blog/widgets.py
index 64509c2..ec1bd1d 100644
--- a/app/blog/widgets.py
+++ b/app/blog/widgets.py
@@ -1,15 +1,15 @@
+import os
from django.contrib.admin.widgets import AdminFileWidget
-from django.utils.translation import ugettext as _
from django.utils.safestring import mark_safe
from django.conf import settings
-from PIL import Image
-import os
+
def thumbnail(image_path):
absolute_url = os.path.join(settings.IMAGES_URL, image_path[7:])
print(absolute_url)
return '<img style="max-width: 400px" src="%s" alt="%s" />' % (absolute_url, image_path)
+
class AdminImageWidget(AdminFileWidget):
"""
A FileField Widget that displays an image instead of a file path
@@ -21,6 +21,6 @@ class AdminImageWidget(AdminFileWidget):
if file_name:
file_path = '%s' % (file_name)
output.append('<a target="_blank" href="%s">%s</a>' % (file_path, thumbnail(file_name)))
-
+
output.append(super(AdminFileWidget, self).render(name, value, attrs))
return mark_safe(''.join(output))