refactored

This commit is contained in:
Anatoly 2019-10-04 14:30:34 +03:00
parent eaa1795f0c
commit 91790bbc39
3 changed files with 2 additions and 4 deletions

View File

@ -6,7 +6,7 @@ from gallery.models import Image
@admin.register(Image) @admin.register(Image)
class ImageModelAdmin(admin.ModelAdmin): class ImageModelAdmin(admin.ModelAdmin):
"""Image model admin.""" """Image model admin."""
list_display = ['id', 'title', 'image_tag', 'orientation_display'] list_display = ['id', 'title', 'orientation_display', 'image_tag', ]
def orientation_display(self, obj): def orientation_display(self, obj):
"""Get image orientation name.""" """Get image orientation name."""

View File

@ -45,8 +45,6 @@ class NewsDocument(Document):
'slug', 'slug',
'state', 'state',
'is_highlighted', 'is_highlighted',
'image_url',
'preview_image_url',
'template', 'template',
) )
related_models = [models.NewsType] related_models = [models.NewsType]

View File

@ -210,7 +210,7 @@ class SORLImageMixin(models.Model):
def image_tag(self): def image_tag(self):
"""Admin preview tag.""" """Admin preview tag."""
if self.image: if self.image:
return mark_safe(f'<img src="{self.image.url}" style="height: 25%; width: 25%" />') return mark_safe(f'<img src="{self.image.url}" style="max-height: 25%; max-width: 25%" />')
else: else:
return None return None