From efb623af0bcb47d510501c282e1326b11343a29c Mon Sep 17 00:00:00 2001 From: luxagraf Date: Sat, 22 Sep 2012 22:27:04 -0400 Subject: site reorg --- apps/blog/widgets.py | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 apps/blog/widgets.py (limited to 'apps/blog/widgets.py') diff --git a/apps/blog/widgets.py b/apps/blog/widgets.py deleted file mode 100644 index a9451e7..0000000 --- a/apps/blog/widgets.py +++ /dev/null @@ -1,32 +0,0 @@ -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 - -try: - from sorl.thumbnail.main import DjangoThumbnail - def thumbnail(image_path): - t = DjangoThumbnail(relative_source=image_path, requested_size=(200,200)) - return u'%s' % (t.absolute_url, image_path) -except ImportError: - def thumbnail(image_path): - absolute_url = os.path.join(settings.IMAGES_URL, image_path) - return u'%s' % (absolute_url, image_path) - -class AdminImageWidget(AdminFileWidget): - """ - A FileField Widget that displays an image instead of a file path - if the current file is an image. - """ - def render(self, name, value, attrs=None): - output = [] - file_name = str(value) - if file_name: - file_path = '%s' % (file_name) - output.append('%s
%s %s
%s ' % \ - (file_path, thumbnail(file_name), _('Currently:'), file_path, file_name, _('Change:'))) - - output.append(super(AdminFileWidget, self).render(name, value, attrs)) - return mark_safe(u''.join(output)) -- cgit v1.2.3-70-g09d2