diff options
Diffstat (limited to 'app/jrnl')
-rw-r--r-- | app/jrnl/admin.py | 13 | ||||
-rw-r--r-- | app/jrnl/widgets.py | 32 |
2 files changed, 2 insertions, 43 deletions
diff --git a/app/jrnl/admin.py b/app/jrnl/admin.py index 15a7512..da4bae3 100644 --- a/app/jrnl/admin.py +++ b/app/jrnl/admin.py @@ -2,7 +2,7 @@ from django.contrib import admin from django import forms from django.contrib.gis.admin import OSMGeoAdmin -from .widgets import AdminImageWidget +from utils.widgets import AdminImageWidget, LGEntryForm from .models import Entry, EntryAside, PostImage, HomepageCurrator @@ -15,17 +15,8 @@ class EntryAsideAdmin(admin.ModelAdmin): pass -class BlogEntryForm(forms.ModelForm): - class Meta: - model = Entry - fields = '__all__' - widgets = { - 'body_markdown': forms.Textarea(attrs={'rows': 50, 'cols': 100}), - } - - class EntryAdmin(OSMGeoAdmin): - form = BlogEntryForm + form = LGEntryForm inlines = [EntryAsideInline] def formfield_for_dbfield(self, db_field, **kwargs): diff --git a/app/jrnl/widgets.py b/app/jrnl/widgets.py deleted file mode 100644 index 030437b..0000000 --- a/app/jrnl/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 '<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 - 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('<span>%s</span><a target="_blank" href="%s">%s</a>' % (help_text, file_path, thumbnail(file_name))) - - output.append(super(AdminFileWidget, self).render(name, value, attrs)) - return mark_safe(''.join(output)) |