refactored
This commit is contained in:
parent
eaa1795f0c
commit
91790bbc39
|
|
@ -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."""
|
||||||
|
|
|
||||||
|
|
@ -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]
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user