From 2311ea934932cf791a83f6c6264063a26468e98c Mon Sep 17 00:00:00 2001 From: luxagraf Date: Wed, 4 Nov 2015 22:09:58 -0500 Subject: refactored blog app and renamed to jrnl --- app/blog/widgets.py | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 app/blog/widgets.py (limited to 'app/blog/widgets.py') diff --git a/app/blog/widgets.py b/app/blog/widgets.py deleted file mode 100644 index 030437b..0000000 --- a/app/blog/widgets.py +++ /dev/null @@ -1,32 +0,0 @@ -import os - -from django.contrib.admin.widgets import AdminFileWidget -from django.utils.safestring import mark_safe -from django.conf import settings - - -def thumbnail(image_path): - absolute_url = os.path.join(settings.IMAGES_URL, image_path[7:]) - print(absolute_url) - return '%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) - help_text = '' - if file_name: - file_path = '%s' % (file_name) - if attrs['id'] == 'id_thumbnail': - help_text = '160 wide' - if attrs['id'] == 'id_image': - help_text = '205px high' - output.append('%s%s' % (help_text, file_path, thumbnail(file_name))) - - output.append(super(AdminFileWidget, self).render(name, value, attrs)) - return mark_safe(''.join(output)) -- cgit v1.2.3-70-g09d2